Permalink
Browse files

BCC headers are removed when sending via SMTP

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1387 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
jamis committed Jun 6, 2005
1 parent ba254b5 commit 508c26c0bbdbe8dbfd8945225d365f8ad06cb616
View
@@ -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]
@@ -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 @@ def create_mail
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
@@ -61,7 +61,7 @@ def delete_no_send_fields
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
@@ -3,6 +3,26 @@
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 @@ def test_html_mail
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

0 comments on commit 508c26c

Please sign in to comment.