Rails - sending emails with a broken name
I am trying to send emails with username to from. Something like "John Doe <john@doe.com>"
. I went through a lot of SO solutions but still couldn't get this to work.
Here's the sender:
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've tried quite a few options above, but nothing seems to work. Would be grateful for solving this problem.
+3
source to share