我有一个应用程序,它使用设计为新注册的用户发送确认邮件,我在 development.rb 文件下有 smtp 设置为
config.action_mailer.default_url_options = { :host => 'http://localhost:3000' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => :login,
:user_name => "my_username@gmail.com",
:password => "mygmail password"
}
这让我犯了一个错误,例如,
Net::SMTPAuthenticationError in Devise::RegistrationsController#create
535-5.7.1 Please log in with your web browser and then try again. Learn more at
任何想法如何解决这个问题?
使用这些设置解决..
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.perform_deliveries = true
config.action_mailer.default :charset => "utf-8"
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => "my_username@gmail.com",
:password => 'my_gmail password',
:authentication => "plain",
:enable_starttls_auto => true
}