【问题标题】:Sending emails from different domains从不同域发送电子邮件
【发布时间】:2021-03-29 06:41:15
【问题描述】:

我们目前正在使用 SendGrid 运行我们的 ruby​​ on rails 应用程序来发送电子邮件。我们在 SendGrid 帐户中验证了两个子域:

  1. test1.mydomain.com
  2. test2.mydomain.com

目前发送邮件的默认域是test1.mydomain.com,在 SendGrid 中配置。

但是我们想从子域test2.mydomain.comtest1.mydomain.com 发送一些电子邮件。是否可以从 ruby​​ on rails 应用程序发送来自不同域的电子邮件?

【问题讨论】:

    标签: ruby-on-rails sendgrid sendgrid-ruby sendgrid-rails


    【解决方案1】:

    其中一部分是为两个域设置 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-04
      • 2012-05-19
      • 1970-01-01
      • 2010-10-26
      • 1970-01-01
      • 2017-06-07
      相关资源
      最近更新 更多