我想從我的Ruby on Rails應用程序中通過Gmail發送的電子郵件來自Ben
。爲什麼我不能在我的Rails應用程序中使用Gmail正確設置FROM名稱?
目前,當電子郵件到達一個(單獨的,無關的)Gmail帳戶時,在收件箱中它的起始部分有ben
。
這裏是我的設置:
爲setup_mail.rb
# my domain is my_example.com, and the email address I am sending from is [email protected]_example.com
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "my_example.com",
:user_name => "[email protected]_example.com",
:password => "my_password",
:authentication => "plain",
:enable_starttls_auto => true
}
if Rails.env.development?
ActionMailer::Base.default_url_options[:host] = "localhost:3000"
else
ActionMailer::Base.default_url_options[:host] = "my_example.com"
end
report_mailer.rb
def send_notification_email(notification_details)
subject = "testing_email"
mail(:to => notification_details[:email], :subject => subject, :from => "Ben")
end
這裏是在Gmail電子郵件設置:
非常感謝您的幫助! – ben 2011-06-19 03:20:06
很高興幫助:) – 2011-06-19 06:05:16
如果你使用的是devise,那麼你可以在'config/initializers/devise.rb'中設置from字段,如下所示:'config.mailer_sender =「\」Awesome Name \「「' –
Automatico
2015-05-29 01:33:36