ruby-on-rails - 连接到 gmail 时 Rails 3.1.0.rc5 中的 Net::SMTPAuthenticationError

标签 ruby-on-rails smtp

每当我尝试在我的 rails 应用程序中发送通知时,我都会收到以下错误

Net::SMTPAuthenticationError (535-5.7.1 Username and Password not accepted. Learn more at                   
):
  app/models/friendship.rb:6:in `send_request'
  app/controllers/friends_controller.rb:21:in `make_friendship'

我的 development.rb 邮件配置设置是
  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = true

  config.action_mailer.delivery_method = :smtp
  # Gmail SMTP server setup
  config.action_mailer.smtp_settings = {
        :address => "smtp.gmail.com",
        :enable_starttls_auto => true,
        :port => 587,
        :domain => '@example.com',
        :authentication => :plain,
        :user_name => 'user@gmail.com',
        :password => 'secret'
  }

最佳答案

我有这个,它对我有用:

  ActionMailer::Base.smtp_settings = {
    :address              => "smtp.gmail.com",
    :port                 => 587,
    :user_name            => "name@example.com",
    :password             => 'password',
    :authentication       => "plain",
    :enable_starttls_auto => true
  }

关于ruby-on-rails - 连接到 gmail 时 Rails 3.1.0.rc5 中的 Net::SMTPAuthenticationError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6956018/

相关文章:

python - 使用 Python 通过邮件发送的附件图像

C#通过Gmail账户发送邮件

ruby-on-rails - Rails 正在向后路由我的 calendar_event_path 吗?

ruby-on-rails - 我如何在 Mongoid & Rails 中使用数组字段?

c# - 电子邮件通知架构问题

php - Swift Mailer 不返回 smtp 邮件失败

smtp 无法在生产环境中工作,即使有凭据也未经过身份验证

ruby-on-rails - 名称已被 Ruby on Rails 使用或保留?

ruby-on-rails - Rails act_as_paranoid 迁移问题

javascript - 渲染:partial generates only one time on escape_javascript