Rails 4 ActionMailer with gmail Net :: SMTPAuthenticationError:534-5.7.14

pig*_*ate 14 apache email gmail ruby-on-rails actionmailer

我正在尝试在我的应用程序的开发版本中发送电子邮件.我所做的一切都在起作用.我一直受到以下打击: Net :: SMTPAuthenticationError:534-5.7.14 https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=blahblahblah

我关注的其他SO帖子:

从Rails应用程序发送电子邮件时的Net :: SMTPAuthenticationError(在登台环境中)

尝试在RoR应用程序中发送电子邮件时遇到SMTP错误

......等......没有任何作用.如果无法解决,我会把我的脑袋撕掉.我花了这么长时间才...

我已尝试直接访问http://www.google.com/accounts/DisplayUnlockCaptcha,然后点击"继续",无结果.我已经在我的Google帐户设置中启用了不太安全的应用访问权限(Google - >安全 - >帐户权限 - >访问权限).我试过去错误后发布的链接,并从那里登录,没有结果.

我在config/environments/development.rb中的设置

  config.action_mailer.default :charset => "utf-8"
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: 'smtp.gmail.com',
    port: 587,
    domain: 'mysite.com',
    user_name: ENV['MAIL_EMAIL'],
    password: ENV['MAIL_PASS'],
    authentication: 'plain',
    enable_starttls_auto: true
  }
Run Code Online (Sandbox Code Playgroud)

如果这有任何区别:

从apache错误日志:

警告:基于名称的SSL虚拟主机仅适用于具有TLS服务器名称指示支持的客户端

我在同一个IP地址上托管两个域.

我将rails应用程序切换到生产模式,看它是否会有所帮助.没有结果.

请帮忙.

Sib*_*ang 29

转到您的Google帐户设置,查找Security -> Account permissions -> Access for less secure apps,启用此选项.

关于此选项:https://support.google.com/accounts/answer/6010255

  • 1000美元答案.最后,经过100次尝试,我才知道这个愚蠢的理由浪费了我2周的时间.谢谢你! (2认同)