ruby-on-rails - 从不同域发送电子邮件
问题描述
我们目前正在使用 SendGrid 运行我们的 ruby on rails 应用程序来发送电子邮件。我们在 SendGrid 帐户中验证了两个子域:
- test1.mydomain.com
- test2.mydomain.com
目前发送电子邮件的默认域test1.mydomain.com
是在 SendGrid 中配置的。
但是我们想从子域发送一些电子邮件,test2.mydomain.com
而从test1.mydomain.com
. 是否可以从 ruby on rails 应用程序发送来自不同域的电子邮件?
解决方案
一部分是为两个域设置 MX 和其他基于 DNS 的验证。如果需要,Sendgrid 文档将为您提供帮助:https ://sendgrid.com/docs/ui/account-and-settings/how-to-set-up-domain-authentication/
然后,在您的邮件中,您可以设置一个“发件人”地址,该地址将显示为发件人。
如果通常您将其配置一次(在 中config/environment/production.rb
)为
config.action_mailer.default_options = {from: 'no-reply@example.com'}
您还可以为每个邮件程序类设置它
class MyAlternativeMailer < ApplicationMailer
default from: "from@altdomain.example.com"
def altmessage
end
end
推荐阅读
- selenium-webdriver - 按钮单击但未单击
- angular - 在 Angular 中使用 forkJoin 时的可重用搜索
- amazon-web-services - 在免费 AWS 层上运行 LAMP 和 Certbot 的 Ubuntu 出现 SSL 超时问题
- php - 通过ajax发送一个php var
- python - 使用 row 函数获取 nan。但是,在将行与 nan 进行比较时,条件变为 False
- docusignapi - 如何在 NetSuite 中将文件(例如 PDF)编码为 base64
- c# - 从不在 MyList 中的实体中选择
(字段)使用实体框架 - php - 使用一个键数组过滤另一个数组,保持“顺序”
- rust - 将参数/标志传递给`build.rs`
- matlab - 在matlab的列中拆分行