Reputation: 107
I'm trying to send mails with the name of the user in the from address. Something like "John Doe <[email protected]>"
. I went through a lot of SO solutions, but still couldn't get this to work.
Here's the mailer:
def trigger_email(send_mail, contact, user)
@mailer = send_mail
@email = contact.email
@user = User.find(user)
mail(to: @email, subject: @mailer.subject, from: "\"#{@user.name}\" <@user.email>")
end
I have tried quite a few variants of the above but nothing works. Would appreciate a solution to this issue.
Upvotes: 3
Views: 113
Reputation: 10796
The from:
value in the mail()
line seems to be wrong. Try:
mail(to: @email, subject: @mailer.subject, from: "#{@user.name} <#{@user.email}>")
If that does not work, check with your email provider, maybe they're altering that?
Upvotes: 2