" . I w...">

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


1 answer


The value from:

in the string mail()

seems to be wrong. Try:

mail(to: @email, subject: @mailer.subject, from: "#{@user.name} <#{@user.email}>")

      



If that doesn't work, please contact your email provider, maybe they change this?

+2


source







All Articles