Guest User

Untitled

a guest
May 2nd, 2018
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. commit da61a6c9671239dbb4a926c3e161ca8663fa0e3f
  2. Author: Joey A <joey@aghion.com>
  3. Date: Fri Aug 7 14:30:01 2009 +0200
  4.  
  5. avoid generating invalid SMTP commands in ruby pre 1.9
  6.  
  7. Signed-off-by: Michael Koziarski <michael@koziarski.com>
  8.  
  9. diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
  10. index 84997de..36122e2 100644
  11. --- a/actionmailer/lib/action_mailer/base.rb
  12. +++ b/actionmailer/lib/action_mailer/base.rb
  13. @@ -675,7 +675,7 @@ module ActionMailer #:nodoc:
  14. def perform_delivery_smtp(mail)
  15. destinations = mail.destinations
  16. mail.ready_to_send
  17. - sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']
  18. + sender = (mail['return-path'] && mail['return-path'].spec) || Array(mail.from).first
  19.  
  20. smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
  21. smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
  22. diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
  23. index db6d3df..d0c0e80 100644
  24. --- a/actionmailer/test/mail_service_test.rb
  25. +++ b/actionmailer/test/mail_service_test.rb
  26. @@ -29,6 +29,18 @@ class TestMailer < ActionMailer::Base
  27. self.body = "Goodbye, Mr. #{recipient}"
  28. end
  29.  
  30. + def from_with_name
  31. + from "System <system@loudthinking.com>"
  32. + recipients "root@loudthinking.com"
  33. + body "Nothing to see here."
  34. + end
  35. +
  36. + def from_without_name
  37. + from "system@loudthinking.com"
  38. + recipients "root@loudthinking.com"
  39. + body "Nothing to see here."
  40. + end
  41. +
  42. def cc_bcc(recipient)
  43. recipients recipient
  44. subject "testing bcc/cc"
  45. @@ -454,6 +466,28 @@ class ActionMailerTest < Test::Unit::TestCase
  46. assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
  47. end
  48.  
  49. + def test_from_without_name_for_smtp
  50. + ActionMailer::Base.delivery_method = :smtp
  51. + TestMailer.deliver_from_without_name
  52. +
  53. + mail = MockSMTP.deliveries.first
  54. + assert_not_nil mail
  55. + mail, from, to = mail
  56. +
  57. + assert_equal 'system@loudthinking.com', from.to_s
  58. + end
  59. +
  60. + def test_from_with_name_for_smtp
  61. + ActionMailer::Base.delivery_method = :smtp
  62. + TestMailer.deliver_from_with_name
  63. +
  64. + mail = MockSMTP.deliveries.first
  65. + assert_not_nil mail
  66. + mail, from, to = mail
  67. +
  68. + assert_equal 'system@loudthinking.com', from.to_s
  69. + end
  70. +
  71. def test_reply_to
  72. expected = new_mail
Add Comment
Please, Sign In to add comment