问题
when I try to send an email via sendgrid on heroku cedar stack, I got an following error :
ArgumentError (SMTP-AUTH requested but missing user name):
my settings in /environments/staging.rb are :
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'myapp' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "587",
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com'
}
My Sendgrid password/username are obtained from Heroku according to this page
Does anyone have any suggestion ?
回答1:
Try moving your config from config/enviornments/staging.rb
into config/initializers/smtp.rb
. That way you know ActionMailer is configured regardless of the environment you're in.
You should keep delivery specific setting in your environment files:
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
来源:https://stackoverflow.com/questions/11426202/error-in-sendgrid-on-heroku-cedar-stack