我有一个应用程序,它使用设计为新注册的用户发送确认邮件,我在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
}
我无法用任何代码解决这个问题。过了一会儿,我登录了gmail帐户,这就是它给我的东西。
We've detected suspicious activity on your Google Account. Please create a new password to continue using your account.
Read some tips on creating a secure password.
因此,此问题的解决方案只需登录您用于发送电子邮件的帐户并重新确认您的新密码
:authentication => 'plain'
# ActionMailer Config
config.action_mailer.default_url_options = {:host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# change to false to prevent email from being sent during development
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "example.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: "your_mail@gmail.com",
password: "your_password"
}
像这样制作您的 development.rb 文件后,如果您有问题,请登录您的 gmail 帐户,该帐户用于 development.rb 文件。然后问题就解决了。