我在Rails 4服务器上集成了Sendgrid设置.这些设置适用于开发环境.但这会给生产环境带来错误.
Net::SMTPFatalError (550 Cannot receive from specified address <simmi@mydomain.com>: Unauthenticated senders not allowed)
配置/初始化/ email_setup.rb
ActionMailer::Base.smtp_settings = { :address => "smtp.sendgrid.net",:domain => DOMAIN,:user_name => ENV['SENDGRID_USERNAME'],:password => ENV['SENDGRID_PASSWORD'],:authentication => "plain",:enable_starttls_auto => true }
配置/初始化/ devise.rb
config.mailer_sender = 'simmi@mydomain.com'
配置/环境/ production.rb
# Default URL config.action_mailer.default_url_options = { host: 'mysite.mydomain.com' } DOMAIN = 'mysite.mydomain.com'