问题
I'm trying to send out "Welcome Emails" to my users, however, the default :from is not working. It is using the user_name I specify in the config/application.rb file.
This is the code I currently have.
config/application.rb
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => "587",
:domain => "domain.com",
:user_name => "myemail@gmail.com",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true
}
user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => 'email_i_want_to_send_from@gmail.com'
def welcome_email
mail(:to => "myemail@gmail.com", :subject => "welcome")
end
end
Instead of receiving an email from email_i_want_to_send_from@gmail.com, a user would receive an email from myemail@gmail.com. (Yes, I am using actual email addresses and passwords when testing).
Anyone have any ideas as to why this is happening? Thanks.
回答1:
Google doesn't allow you to "spoof" a from address. I used Send Grid to send out my emails.
来源:https://stackoverflow.com/questions/10355769/actionmailer-doesnt-use-default-from-or-any-from-for-that-matter