我在我的开发(本地)环境以及当我尝试从我的rails应用程序发送邮件时,我在Heroku上主持了Net::SMTPAuthenticationError
。
这是在发送前几封电子邮件(两封邮件具体)后开始的。
到目前为止,所有研究都认为这可能是因为在Gmail帐户上启用了2-factor auth
,但是当我检查帐户时,2-factor autt
未启用。
是config/development.rb
和config/production.rb
中的smtp设置:
config.action_mailer.delivery_method = :smtp
# SMTP settings for gmail
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => Rails.configuration.gmail_address,
:password => Rails.configuration.gmail_password,
:authentication => "plain",
:enable_starttls_auto => true
}
我的邮件设置如下:
class StackoMailer < ActionMailer::Base
def success_mail
@my_email = Rails.configuration.gmail_address
mail(
from: 'notifications@StackoProbe.com',
to: @my_email,
subject: 'Fuck Yeah! Visited successfully...'
)
end
end
在调用PushWatir::StackoMailer.success_mail.deliver_now!
时,我收到以下错误:
2.2.1 :001 > PushWatir::StackoMailer.success_mail.deliver_now!
Net::SMTPAuthenticationError: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbv8i
from /Users/andela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:976:in `check_auth_response'
from /Users/andela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:740:in `auth_plain'
from /Users/andela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:732:in `authenticate'
from /Users/andela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:567:in `do_start'
from /Users/andela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:520:in `start'
from /Users/andela/.rvm/gems/ruby-2.2.1/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
from /Users/andela/.rvm/gems/ruby-2.2.1/gems/mail-2.6.3/lib/mail/message.rb:252:in `deliver!'
from /Users/andela/.rvm/gems/ruby-2.2.1/gems/actionmailer-4.2.4/lib/action_mailer/message_delivery.rb:77:in `deliver_now!'
from (irb):1
from /Users/andela/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start'
from /Users/andela/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start'
from /Users/andela/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/andela/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/andela/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
2.2.1 :002 >
导致这种情况的原因是什么?
我该如何使这项工作?非常感谢您的回复
答案 0 :(得分:1)
对我有用的解决方案之一是允许我的Google帐户使用“安全性较低的应用”。
执行此操作的步骤如下: -
从您的Google帐户设置中,找到“登录和安全” - &gt; “允许安全性较低的应用”,启用它。