Email Net::设置用户确认时设备中出现SMTPAuthenticationError
当我尝试在Rails应用程序中设置用户确认时,出现以下错误Email Net::设置用户确认时设备中出现SMTPAuthenticationError,email,devise,sendgrid,confirmation,Email,Devise,Sendgrid,Confirmation,当我尝试在Rails应用程序中设置用户确认时,出现以下错误 Net::SMTPAuthenticationError in Devise::ConfirmationsController#create 535 Authentication failed: Bad username / password 我查看了终端,电子邮件已经设置好了,但没有发送。 s 不确定我需要发布哪些部分的代码,但下面是我的config/environments/developer文件和setup\u mail.fil
Net::SMTPAuthenticationError in Devise::ConfirmationsController#create
535 Authentication failed: Bad username / password
我查看了终端,电子邮件已经设置好了,但没有发送。
s
不确定我需要发布哪些部分的代码,但下面是我的config/environments/developer文件和setup\u mail.file中的代码
有什么想法吗?我不知道这里发生了什么
development:
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.raise_runtime_errors = true
config.action_mailer.default_url_options = {host: 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
end
setup_mail
if Rails.env.development?
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: 'smtp.sendgrid.net',
port: '587',
authentication: :plain,
user_name: ENV['SENDGRID_USERNAME'],
password: ENV['SENDGRID_PASSWORD'],
domain: 'heroku.com',
enable_starttls_auto: true
}
end
Heroku将默认使用rails生产环境。您仅为开发环境定义了邮件程序设置。将配置移动到
config/environment.rb
或config/environments/production.rb
可以解决您的问题
您可以参考以获取更多信息。您是否100%确定您的环境变量设置正确?试着在应用程序中的某个地方打印出来确认。你是如何做到的?对不起,我是Ruby和Rails的新手,不用担心。在您知道将要执行的代码中的某个地方,放置puts******************************************puts ENV['SENDGRID\u USERNAME']puts ENV['SENDGRID\u PASSWORD']puts*******************我使用了
heroku config
来确保SENDGRID帐户信息正确。因此heroku将使用您的生产环境,而不是您的开发环境。如果您在本地进行测试,则开发是必要的。我想这就是问题所在。