diff options
Diffstat (limited to 'app/mailers')
-rw-r--r-- | app/mailers/emails/projects.rb | 14 | ||||
-rw-r--r-- | app/mailers/notify.rb | 22 |
2 files changed, 24 insertions, 12 deletions
diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 2584e9d48b1..0dbb2939bb3 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -125,9 +125,17 @@ module Emails @disable_footer = true - mail(from: sender(author_id, send_from_committer_email), - to: recipient, - subject: @subject) + reply_to = + if send_from_committer_email && can_send_from_user_email?(@author) + @author.email + else + Gitlab.config.gitlab.email_reply_to + end + + mail(from: sender(author_id, send_from_committer_email), + reply_to: reply_to, + to: recipient, + subject: @subject) end end end diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 7c8b37029d1..2c0d451511f 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -60,20 +60,24 @@ class Notify < ActionMailer::Base address end + def can_send_from_user_email?(sender) + sender_domain = sender.email.split("@").last + self.class.allowed_email_domains.include?(sender_domain) + end + # Return an email address that displays the name of the sender. # Only the displayed name changes; the actual email address is always the same. def sender(sender_id, send_from_user_email = false) - if sender = User.find(sender_id) - address = default_sender_address - address.display_name = sender.name + return unless sender = User.find(sender_id) + + address = default_sender_address + address.display_name = sender.name - sender_domain = sender.email.split("@").last - if send_from_user_email && self.class.allowed_email_domains.include?(sender_domain) - address.address = sender.email - end - - address.format + if send_from_user_email && can_send_from_user_email?(sender) + address.address = sender.email end + + address.format end # Look up a User by their ID and return their email address |