Allow User objects in From mail field and set Reply-To if not set already
This commit is contained in:
parent
b5c9634315
commit
c71b91a32f
2 changed files with 7 additions and 4 deletions
|
@ -63,7 +63,7 @@ class Mailer < ActionMailer::Base
|
||||||
@feedback = feedback
|
@feedback = feedback
|
||||||
|
|
||||||
mail to: FoodsoftConfig[:notification][:error_recipients],
|
mail to: FoodsoftConfig[:notification][:error_recipients],
|
||||||
:from => "#{show_user user} <#{user.email}>",
|
from: user,
|
||||||
subject: I18n.t('mailer.feedback.subject', email: user.email)
|
subject: I18n.t('mailer.feedback.subject', email: user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,6 +78,11 @@ class Mailer < ActionMailer::Base
|
||||||
def mail(args)
|
def mail(args)
|
||||||
args[:subject] = "[#{FoodsoftConfig[:name]}] #{args[:subject]}"
|
args[:subject] = "[#{FoodsoftConfig[:name]}] #{args[:subject]}"
|
||||||
|
|
||||||
|
if args[:from].is_a? User
|
||||||
|
args[:reply_to] = args[:from] unless args[:reply_to]
|
||||||
|
args[:from] = "#{show_user args[:from]} via #{I18n.t('layouts.foodsoft')} <#{FoodsoftConfig[:email_sender]}>"
|
||||||
|
end
|
||||||
|
|
||||||
[:bcc, :cc, :reply_to, :sender, :to].each do |k|
|
[:bcc, :cc, :reply_to, :sender, :to].each do |k|
|
||||||
user = args[k]
|
user = args[k]
|
||||||
args[k] = "#{show_user user} <#{user.email}>" if user.is_a? User
|
args[k] = "#{show_user user} <#{user.email}>" if user.is_a? User
|
||||||
|
|
|
@ -7,13 +7,11 @@ class MessagesMailer < Mailer
|
||||||
if reply_email_domain
|
if reply_email_domain
|
||||||
hash = message.mail_hash_for_user recipient
|
hash = message.mail_hash_for_user recipient
|
||||||
reply_to = "#{I18n.t('layouts.foodsoft')} <#{FoodsoftConfig.scope}.#{message.id}.#{recipient.id}.#{hash}@#{reply_email_domain}>"
|
reply_to = "#{I18n.t('layouts.foodsoft')} <#{FoodsoftConfig.scope}.#{message.id}.#{recipient.id}.#{hash}@#{reply_email_domain}>"
|
||||||
else
|
|
||||||
reply_to = "#{show_user(message.sender)} <#{message.sender.email}>"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
mail subject: message.subject,
|
mail subject: message.subject,
|
||||||
to: recipient,
|
to: recipient,
|
||||||
from: "#{show_user(message.sender)} via #{I18n.t('layouts.foodsoft')} <#{FoodsoftConfig[:email_sender]}>",
|
from: message.sender,
|
||||||
reply_to: reply_to
|
reply_to: reply_to
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue