From 21e503fc7100049131c41d27a33ec62094135263 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Fri, 15 Feb 2019 23:52:30 +0000 Subject: Show author's name in the From field of email notifications (#5913). Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@17870 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mailer.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 492ca976d..dc155648e 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -615,13 +615,21 @@ class Mailer < ActionMailer::Base end 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 && @author.logged?) ? @author.name : Setting.app_title + end + headers.reverse_merge! 'X-Mailer' => 'Redmine', 'X-Redmine-Host' => Setting.host_name, 'X-Redmine-Site' => Setting.app_title, 'X-Auto-Response-Suppress' => 'All', 'Auto-Submitted' => 'auto-generated', - 'From' => Setting.mail_from, - 'List-Id' => "<#{Setting.mail_from.to_s.tr('@', '.')}>" + 'From' => mail_from.format, + 'List-Id' => "<#{mail_from.address.to_s.tr('@', '.')}>" # Replaces users with their email addresses [:to, :cc, :bcc].each do |key| -- cgit v1.2.3