One of my mailers looks like this:
mail(:from => "Support Team <[email protected]>",
:to => "#{@user.alias} <#{@user.email}>",
:subject => 'Verification Email')
However, if the alias of the user is "Foobar, Bar", then the email actually gets sent to: Foobar, Bar <[email protected]>
. i.e. to foobar and to composer.
I think the problem is with the comma in "Foobar, Bar". Does this need to be escaped or something?
Should my mailer look like this instead:
mail(:from => "Support Team <[email protected]>",
:to => @user.email,
:subject => 'Verification Email')
Go to the config folder of your emails project and open environment. rb file and add the following line at the bottom of this file. It tells ActionMailer that you want to use the SMTP server. You can also set it to be :sendmail if you are using a Unix-based operating system such as Mac OS X or Linux.
Action Mailer allows you to send emails from your application using a mailer model and views. So, in Rails, emails are used by creating mailers that inherit from ActionMailer::Base and live in app/mailers. Those mailers have associated views that appear alongside controller views in app/views.
Certainly spaces (and possibly commas) in the name part of an email header must be included within quotes.
Quoting a name is sometimes optional, but never forbidden, so for simplicity, try:
mail(:from => "\"Support Team\" <[email protected]>",
:to => "\"#{@user.alias}\" <#{@user.email}>",
:subject => 'Verification Email')
EDIT For completeness, I have added escaped quotes to from
, because they should also be necessary.
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