]> source.dussan.org Git - redmine.git/commitdiff
Adds a X-Redmine-Sender header to email notifications (#5643).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 5 Feb 2012 12:57:19 +0000 (12:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 5 Feb 2012 12:57:19 +0000 (12:57 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8785 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mailer.rb
test/unit/mailer_test.rb

index bd94b9f5b882d64a07831b6c9da9aa35bb21145b..2502ce2e04f02d9ee1f494129481232099f5b2d4 100644 (file)
@@ -41,6 +41,7 @@ class Mailer < ActionMailer::Base
                     'Issue-Author' => issue.author.login
     redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
     message_id issue
+    @author = issue.author
     recipients issue.recipients
     cc(issue.watcher_recipients - @recipients)
     subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
@@ -394,6 +395,10 @@ class Mailer < ActionMailer::Base
       cc.delete(@author.mail) if cc
     end
 
+    if @author.logged?
+      redmine_headers 'Sender' => @author.login
+    end
+
     notified_users = [recipients, cc].flatten.compact.uniq
     # Rails would log recipients only, not cc and bcc
     mylogger.info "Sending email notification to: #{notified_users.join(', ')}" if mylogger
index 042b8c36ce42e386873227028b8bfe8b7cd82839..9e32918bfe9c9a01cb44cad52a2f8e1d8163cc71 100644 (file)
@@ -138,6 +138,14 @@ class MailerTest < ActiveSupport::TestCase
     assert_equal 'auto-generated', mail.header_string('Auto-Submitted')
   end
 
+  def test_email_headers_should_include_sender
+    issue = Issue.find(1)
+    Mailer.deliver_issue_add(issue)
+    mail = ActionMailer::Base.deliveries.last
+    assert_not_nil mail
+    assert_equal issue.author.login, mail.header_string('X-Redmine-Sender')
+  end
+
   def test_plain_text_mail
     Setting.plain_text_mail = 1
     journal = Journal.find(2)