diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-27 17:54:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-27 17:54:02 +0000 |
commit | 5c0d38f6749e91c9847f6a4d56264d83253b3539 (patch) | |
tree | 77f73acea1466ea5c314b857480f208137576690 /actionmailer/lib/action_mailer | |
parent | f5b991d76dc5d21f1870da067fb3101440256fba (diff) | |
download | rails-5c0d38f6749e91c9847f6a4d56264d83253b3539.tar.gz rails-5c0d38f6749e91c9847f6a4d56264d83253b3539.tar.bz2 rails-5c0d38f6749e91c9847f6a4d56264d83253b3539.zip |
Fixed that a return-path header would be ignored (closes #7572) [joost]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9099 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index ab3ca7f1be..56db84f17c 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -40,10 +40,14 @@ module ActionMailer #:nodoc: # * <tt>content_type</tt> - Specify the content type of the message. Defaults to <tt>text/plain</tt>. # * <tt>headers</tt> - Specify additional headers to be set for the message, e.g. <tt>headers 'X-Mail-Count' => 107370</tt>. # + # When a <tt>headers 'return-path'</tt> is specified, that value will be used as the 'envelope from' + # address. Setting this is useful when you want delivery notifications sent to a different address than + # the one in <tt>from</tt>. + # # The <tt>body</tt> method has special behavior. It takes a hash which generates an instance variable # named after each key in the hash containing the value that that key points to. # - # So, for example, <tt>body "account" => recipient</tt> would result + # So, for example, <tt>body :account => recipient</tt> would result # in an instance variable <tt>@account</tt> with the value of <tt>recipient</tt> being accessible in the # view. # @@ -590,14 +594,16 @@ module ActionMailer #:nodoc: def perform_delivery_smtp(mail) destinations = mail.destinations mail.ready_to_send + sender = mail['return-path'] || mail.from Net::SMTP.start(smtp_settings[:address], smtp_settings[:port], smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp| - smtp.sendmail(mail.encoded, mail.from, destinations) + smtp.sendmail(mail.encoded, sender, destinations) end end def perform_delivery_sendmail(mail) + sendmail_settings[:arguments] += " -f \"#{mail['return-path']}\"" if mail['return-path'] IO.popen("#{sendmail_settings[:location]} #{sendmail_settings[:arguments]}","w+") do |sm| sm.print(mail.encoded.gsub(/\r/, '')) sm.flush |