I'm trying to send out emails that display as from "My Name" rather than "[email protected]"
In my 'User_Mailer' class I have the line:
default :from => "[email protected]"
With that everything works perfectly. I change it to any of the below however and it never reaches the recipient.
default :from => "Name <[email protected]>"
default :from => '"Name" <[email protected]>'
default :from => "\"Name\" <[email protected]>"
... the list goes on.
What exactly should the syntax for that line be? I feel like I've tried everything.
I don't know if something got lost in transcription, but while the first alternative may or may not be fine, the second two aren't even valid Ruby syntax.
In any event, if you look at Rails ActionMailer - format sender and recipient name/email address, the accepted answer implies that you need to quote the "name" part of the address within the string, as in '"Name" <[email protected]>'
However, a highly upvoted answer at https://stackoverflow.com/a/8106387/1008891, suggests that the inner quotes are not necessary and your first alternative format is perfectly fine.
I couldn't find anything in the ActionMailer documentation.
Your last attempt is very close, you just need to escape the closing "
around the name.
default :from => "\"Name\" <[email protected]>"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With