Sparkpost Rails 发送域被拒绝

Sparkpost Rails sending domain rejected

我正在使用此 guide 作为参考来为我的 Rails 应用程序设置 ActionMailer,但每当我尝试发送邮件时都会收到此错误。我也尝试使用与指南完全相同的设置进行复制,但我仍然遇到相同的错误。

550 5.7.1 Unconfigured Sending Domain <gmail.com>

我已经正确配置了我的发送域,例如 Sparkpost 的 myapp.com 标记为准备发送 这是我的 rails actionmailer 设置在 rails 应用程序的生产和开发设置下。

config.action_mailer.smtp_settings = {
user_name: 'SMTP_Injection',
password: 'my_api_key',
address: 'smtp.sparkpostmail.com',
port: 587,
enable_starttls_auto: true,
domain: 'myapp.com'

}

问题不在你的rails代码中

这里有一篇 SparkPost 文章回答了您的问题

The message will be rejected if you are sending from a domain that you have not yet added or configured. Please go to https://app.sparkpost.com/#/account/sending-domains to configure your domain.

Unverified Sending Domain: The message will be rejected if you are sending from a domain that has been configured but not yet verified.

请访问本官方link参考

如果您在 Rails 应用程序中使用 Devise,请不要忘记在配置设置中为 Devise 配置邮件发件人设置以及我忘记做的 smtp 设置。

config.mailer_sender = your sending email address

您必须遵循此 https://support.sparkpost.com/customer/portal/articles/1933318-creating-sending-domains. BTW, I created this gem https://github.com/dmitrypol/sparkpost 才能与 Sparkpost API 互动。注意事项 - beta/alpha 质量非常好。