Reputation: 41874
In Gmail, the following email address
class UserMailer < ActionMailer::Base
default from: '[email protected]'
end
Turns into this (the second item)
Is there anyway to have the "from" address be "no-reply" but have the from name be something more meaningful?
I have noticed my email form SumAll renders as from "SumAll" but with a different reply to address as below:
From: =?utf-8?Q?SumAll?= <[email protected]>
Any idea how to manage this with Action Mailer?
Upvotes: 4
Views: 1825
Reputation: 13344
Check out section 2.3.4 of the ActionMailer documentation.
Specifically:
2.3.4 Sending Email With Name
Sometimes you wish to show the name of the person instead of just their email address when they receive the email. The trick to doing that is to format the email address in the format "Full Name ".
def welcome_email(user)
@user = user
email_with_name = "#{@user.name} <#{@user.email}>"
mail(to: email_with_name, subject: 'Welcome to My Awesome Site')
end
If it's the same sender for all emails in your mailer, I'd suggest trying default from: "Some name <[email protected]>"
- this should work as well.
Upvotes: 7