Mailgun: wildcard subdomain “from-address” for SaaS

萝らか妹 提交于 2019-12-11 04:42:08

问题


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

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.

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>


回答1:


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

Receiving:

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

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) 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.

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.




回答2:


Let's start with understanding how email works. Receiver of the email checks for the dns records of sending domain for example your primary domain is yourdomain.com and email is sent from yourdomain.com will work since you have record created under this already when your email is sent from saas.yourdomain.com then DNS record for saas.yourdomain.com should exist or else it will fail to deliver to inbox. Mailgun asks to verify to make sure it is delivered to inbox and receiver makes sure by checking DNS that it is coming from authentic person by looking up at the DNS.

So the answer is as long as your sending domain is same then you will not create it but if your sending domain is different then you will have to create

Hope this answers your question.



来源:https://stackoverflow.com/questions/44303110/mailgun-wildcard-subdomain-from-address-for-saas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!