Skip to content

Instantly share code, notes, and snippets.

@superdaigo
Last active January 1, 2016 10:19
Show Gist options
  • Save superdaigo/8131115 to your computer and use it in GitHub Desktop.
Save superdaigo/8131115 to your computer and use it in GitHub Desktop.
Redmine 2.3-stable: Append project identifier into mail header 'List-ID'
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index c12195a..9819776 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -388,6 +388,31 @@ class Mailer < ActionMailer::Base
'From' => Setting.mail_from,
'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
+ # set List-ID
+ if @issue
+ project_id = @issue.project.identifier
+ end
+ if @document
+ project_id = @document.project.identifier
+ end
+ if @attachments
+ project_id = @attachments.first.container.project.identifier
+ end
+ if @news
+ project_id = @news.project.identifier
+ end
+ if @message
+ project_id = @message.project.identifier
+ end
+ if @wiki_content
+ project_id = @wiki_content.project.identifier
+ end
+ if project_id
+ headers 'List-ID' => "#{Setting.host_name}/#{project_id}"
+ else
+ headers 'List-ID' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
+ end
+
# Removes the author from the recipients and cc
# if he doesn't want to receive notifications about what he does
if @author && @author.logged? && @author.pref.no_self_notified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment