3

我有一个应用程序,它使用设计为新注册的用户发送确认邮件,我在 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
  }
4

3 回答 3

3

我无法用任何代码解决这个问题。过了一会儿,我登录了 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. 

所以解决这个问题的方法是简单地登录您用于发送电子邮件的帐户并重新确认您的新密码

于 2013-01-27T10:44:22.823 回答
1

:authentication => '普通'

于 2012-05-23T11:47:36.237 回答
0

# ActionMailer 配置

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 文件中使用。那么问题就解决了。

于 2013-06-04T09:58:20.327 回答