diff options
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/CHANGELOG | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 6 | ||||
-rwxr-xr-x | actionmailer/lib/action_mailer/vendor/tmail/net.rb | 2 | ||||
-rwxr-xr-x | actionmailer/test/mail_service_test.rb | 30 |
4 files changed, 38 insertions, 2 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index 7eeed73fc7..632791d8af 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* BCC headers are removed when sending via SMTP #1402 + * Added 'content_type' accessor, to allow content type to be set on a per-message basis. content_type defaults to "text/plain". * Silently ignore Iconv::IllegalSequence errors when converting text #1341 [lon@speedymac.com] diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 59ee47a137..910ee8dd5b 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -1,5 +1,6 @@ require 'action_mailer/adv_attr_accessor' require 'action_mailer/part' +require 'tmail/net' module ActionMailer #:nodoc: # Usage: @@ -280,9 +281,12 @@ module ActionMailer #:nodoc: end def perform_delivery_smtp(mail) + destinations = mail.destinations + mail.ready_to_send + Net::SMTP.start(server_settings[:address], server_settings[:port], server_settings[:domain], server_settings[:user_name], server_settings[:password], server_settings[:authentication]) do |smtp| - smtp.sendmail(mail.encoded, mail.from, mail.destinations) + smtp.sendmail(mail.encoded, mail.from, destinations) end end diff --git a/actionmailer/lib/action_mailer/vendor/tmail/net.rb b/actionmailer/lib/action_mailer/vendor/tmail/net.rb index 0ef433b88a..202bc22672 100755 --- a/actionmailer/lib/action_mailer/vendor/tmail/net.rb +++ b/actionmailer/lib/action_mailer/vendor/tmail/net.rb @@ -61,7 +61,7 @@ module TMail end def add_message_id( fqdn = nil ) - self.message_id = ::TMail::new_msgid(fqdn) + self.message_id = ::TMail::new_message_id(fqdn) end def add_date diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 8116d41ca5..3695aa1a15 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -3,6 +3,26 @@ $:.unshift(File.dirname(__FILE__) + "/../lib/") require 'test/unit' require 'action_mailer' +class MockSMTP + def self.deliveries + @@deliveries + end + + def initialize + @@deliveries = [] + end + + def sendmail(mail, from, to) + @@deliveries << [mail, from, to] + end +end + +class Net::SMTP + def self.start(*args) + yield MockSMTP.new + end +end + class TestMailer < ActionMailer::Base def signed_up(recipient) @@ -467,5 +487,15 @@ EOF assert_equal "text/html", mail.content_type end + def test_headers_removed_on_smtp_delivery + ActionMailer::Base.delivery_method = :smtp + TestMailer.deliver_cc_bcc(@recipient) + assert MockSMTP.deliveries[0][2].include?("root@loudthinking.com") + assert MockSMTP.deliveries[0][2].include?("nobody@loudthinking.com") + assert MockSMTP.deliveries[0][2].include?(@recipient) + assert_match %r{^Cc: nobody@loudthinking.com}, MockSMTP.deliveries[0][0] + assert_match %r{^To: #{@recipient}}, MockSMTP.deliveries[0][0] + assert_no_match %r{^Bcc: root@loudthinking.com}, MockSMTP.deliveries[0][0] + end end |