我每次尝试通过rails'localhost'或'c9'发送电子邮件时,都会遇到链接中显示的错误。我在Google帐户上启用了“安全性较低的应用”,并尝试了所有指南,但错误仍然相同。寻求帮助的人。 error snapshotAction Mailer Returning SMTPAuthentcationError
源文件是如下: suggestion_mailer.rb
class SuggestionMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.suggestion_mailer.new_suggestion.subject
#
def new_suggestion()
#@suggestion = suggestion
mail(:from => "[email protected]",
:to => "yyyyyyyyyyyyyygmail.com",
:subject => 'Thanks for signing up for our amazing app'
)
end
end
suggestion_controller.rb
def create
@suggestion = Suggestion.new(suggestion_params)
respond_to do |format|
if @suggestion.save
SuggestionMailer.new_suggestion().deliver
format.html { redirect_to suggestions_url, notice: 'Suggestion was
successfully created.' }
format.json { render :show, status: :created, location:
@suggestion }
else
format.html { render :new }
format.json { render json: @suggestion.errors, status:
:unprocessable_entity }
end
end
端
development.rb
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:domain => "mail.google.com",
:port => 587,
:user_name => ENV['GMAIL_USERNAME'],
:password => ENV['GMAIL_PASSWORD'],
:authentication => "plain",
:enable_starttls_auto => true
#:openssl_verify_mode => 'none'
}
config.action_mailer.default_url_options = { host: 'localhost',
port: 3000 }
嘿部署的应用程序,只是想你的建议,但仍然没有成功。我认为问题是谷歌ACC设置(纠正我,如果我错了),我只是不知道如何去做。谢谢您的好意。 –
据我所知,我们无需进行任何Google设置。你确定你使用的是正确的凭证。也许尝试直接替换用户名和密码,而不使用环境变量。如果是这个问题? – Aakanksha
您必须在谷歌中启用安全性较低的应用。我已经尝试使用环境变量以外的原始凭据,但仍然无法正常工作。 –