Mailgun:通配符子域“发件人地址"用于SaaS

问题描述:

我有一个小的SaaS,每个客户端都获得一个子域(stackexchange.my-saas.com)

I've a small SaaS where each client gets a subdomain (stackexchange.my-saas.com)

我有一个mailgun帐户,在其中设置了我的主域,并且已经在DNS中创建了通配符SPF记录,如果我将其他域添加到带有子域的mailgun帐户中,它们都将正确验证.

I've a mailgun account where my main domain is setup and I've created a wildcard SPF record in my DNS and if I add additional domains to my mailgun account with a subdomain, they all verifies correctly.

我的问题是,当我具有通配符SPF记录集时,是否需要在mailgun中将每个新客户端子域添加为新域,还是可以合法地"为每个新客户端创建一个发件人地址,因此电子邮件将来自:Stack Exchange On My SaaS<noreply@stackexchange.my-saas.com>

My question is, do I need to add every new clients subdomain as a new domain in mailgun when I have the wildcard SPF record set or can i "legally" just create a from-address for each new client so the header of the emails will be from: Stack Exchange On My SaaS<noreply@stackexchange.my-saas.com>

发送:

无需发送.如您所指出的,您可以设置SPF记录,以便可以将电子邮件发送到From:的任何子域.但是请注意,如果Mailgun与您的From:标头不匹配,则会添加与您要发送的注册域相匹配的Sender:标头.

Sending:

For sending, no need. As you point out, you can have the SPF records set so your email can be sent From: whatever subdomain. Note however that Mailgun will add a Sender: header matching the registered domain you are using to send if the do not match your From: header.

From: Stack Exchange On My SaaS <noreply@stackexchange.my-saas.com>
Sender: noreply=stackexchange.my-saas.com@my-saas.com

接收:

对于接收电子邮件,情况则不同.这是Mailgun的限制,已在其他问题中得到了解答.

Receiving:

For receiving emails, it's a different story. This is a Mailgun limitation and has been answered in this other question.

基本上,Mailgun为每个人使用相同的MX服务器,因此,当他们收到一封电子邮件时,他们需要查找该电子邮件所属的客户,就像任何常规的多主机邮件服务器一样.

Basically, Mailgun uses the same MX servers for everybody, so when they get an email they need to look up to which customer the email belongs to, much like any regular multi-host mail server.

(UPDATE)它们允许注册通配符子域,并与通配符MX结合使用,它可能仅适用于每个子域.但是请注意,由于DNS的工作原理,在同一个域中既没有标准方法也不能同时定义通配符MX和通配符CNAME. CloudFlare目前正在支持此功能,但是对于其他大多数DNS提供商而言,它都会失败.

(UPDATE) They allow to register wildcard subdomains, combined with a wildcard MX, it might just work for every subdomain. Note however that because of how DNS works, there is no standard way to define BOTH a wildcard MX and a wildcard CNAME in the same domain. CloudFlare is currently supporting this but it will fail for most other DNS providers.

或者,要在SaaS中接收电子邮件,您必须向Mailgun独立注册每个子域(可以通过其API).请注意,这还意味着要验证在DNS上为每个记录添加TXT记录的域.

Alternatively, for receiving emails in your SaaS, you have to register each of your subdomains with Mailgun independently (possible through their API). Note that this also implies verifying the domains adding TXT records for each one on your DNS.