|
|
@@ -629,10 +629,19 @@ class Mailer < ActionMailer::Base |
|
|
|
def mail(headers={}, &block) |
|
|
|
# Add a display name to the From field if Setting.mail_from does not |
|
|
|
# include it |
|
|
|
mail_from = Mail::Address.new(Setting.mail_from) |
|
|
|
if mail_from.display_name.blank? && mail_from.comments.blank? |
|
|
|
mail_from.display_name = |
|
|
|
@author&.logged? ? @author.name : Setting.app_title |
|
|
|
begin |
|
|
|
mail_from = Mail::Address.new(Setting.mail_from) |
|
|
|
if mail_from.display_name.blank? && mail_from.comments.blank? |
|
|
|
mail_from.display_name = |
|
|
|
@author&.logged? ? @author.name : Setting.app_title |
|
|
|
end |
|
|
|
from = mail_from.format |
|
|
|
list_id = "<#{mail_from.address.to_s.tr('@', '.')}>" |
|
|
|
rescue Mail::Field::IncompleteParseError |
|
|
|
# Use Setting.mail_from as it is if Mail::Address cannot parse it |
|
|
|
# (probably the emission address is not RFC compliant) |
|
|
|
from = Setting.mail_from.to_s |
|
|
|
list_id = "<#{from.tr('@', '.')}>" |
|
|
|
end |
|
|
|
|
|
|
|
headers.reverse_merge! 'X-Mailer' => 'Redmine', |
|
|
@@ -640,8 +649,8 @@ class Mailer < ActionMailer::Base |
|
|
|
'X-Redmine-Site' => Setting.app_title, |
|
|
|
'X-Auto-Response-Suppress' => 'All', |
|
|
|
'Auto-Submitted' => 'auto-generated', |
|
|
|
'From' => mail_from.format, |
|
|
|
'List-Id' => "<#{mail_from.address.to_s.tr('@', '.')}>" |
|
|
|
'From' => from, |
|
|
|
'List-Id' => list_id |
|
|
|
|
|
|
|
# Replaces users with their email addresses |
|
|
|
[:to, :cc, :bcc].each do |key| |