ActionMailer does not send emails properly if: there is a comma in the field

One of my email programs is as follows:

mail(:from => "Support Team <support@email.com>",
     :to => "#{@user.alias} <#{@user.email}>",
     :subject => 'Verification Email')

However, if the user's nickname - "Foobar, Bar", then the email is actually sent to the following address: Foobar, Bar <foobar@gmail.com>. that is, to foobar and to the composer.

I think the problem is with the comma in "Foobar, Bar". Does it need to run or something else?

Should my handwriting look like this:

mail(:from => "Support Team <support@email.com>",
     :to => @user.email,
     :subject => 'Verification Email')
+5
source share
1 answer

Of course, spaces (and possibly commas) in the title part of the email header should be enclosed in quotation marks.

Quote: a name is sometimes optional but never forbidden, so for simplicity try:

mail(:from => "\"Support Team\" <support@email.com>",
     :to => "\"#{@user.alias}\" <#{@user.email}>",
     :subject => 'Verification Email')

EDIT from, .

+9

All Articles