我一直在尝试直接为Rails App集成SendGrid的SMTP设置,以避免使用Heroku帐户的附加组件。根据{{3}},我遵循指示,但奇怪的是收到错误消息,请参阅下文。
Heroku日志(错误):
Net::SMTPFatalError (550 Unauthenticated senders not allowed
到config / environment.rb
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
ActionMailer::Base.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
答案 0 :(得分:4)
您必须确保在heroku配置中设置了SENDGRID_USERNAME
和SENDGRID_PASSWORD
。
要从命令行执行此操作:
heroku config:set SENDGRID_USERNAME=my_username SENDGRID_PASSWORD=my_pass -app my_app