我在heroku上运行它。我已经使用sparkpost验证了域。它说准备发送。我将实际网址更改为“示例”。
mailers / order_mailer.rb
class OrderMailer < ActionMailer::Base
default from: "orders@example.com"
def new_order(order)
@order = order
mail(to: @order.user.email, subject: 'Order Created!')
end
end
config / environments / production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: ENV['SPARKPOST_SMTP_HOST'],
port: ENV['SPARKPOST_SMTP_PORT'],
user_name: ENV['SPARKPOST_SMTP_USERNAME'],
password: ENV['SPARKPOST_SMTP_PASSWORD'],
domain: 'example.com',
authentication: :plain
}
config.action_mailer.default_url_options = {
:host => 'example.com'
}
错误
2018-10-10T02:01:02.371812+00:00 app[web.1]: [3054201e-f06a-4acd-bff8-58947353fb72] Net::SMTPFatalError (550 5.7.1 Unconfigured Sending Domain <example.com>
我想不出什么了,但是如果您有任何需要,请告诉我。