Configure Email for Your Domain with Cloudflare
Configure Email for Your Domain with Cloudflare
Get a domain name
You can get a domain name from any domain name registrar. I use Google Domain, but you can use any registrar you like.
Google Domain 很不错,提供免费的 Whois Privacy 和 DNSSEC。最重要的是界面设计简洁、逻辑清晰,对刚入门的我非常非常友好。提供的服务合适,设置不需要复杂的操作,相关文档详细,汉化完整,通俗易懂。
Sign up for Cloudflare
Cloudflare is a CDN service provider. It provides a free plan, which is enough for most of us.
Add your domain to Cloudflare
-
Cloudflare will scan your DNS records and import them to Cloudflare
-
Cloudflare will provide you with two nameservers, which you need to set in your domain registrar
-
Wait for a few minutes, and your domain will be added to Cloudflare
Configure Email for Your Domain
使用邮件路由功能,会自动添加相关的 DNS 记录,无需手动添加。非常方便。
-
Go to the DNS page of your domain in Cloudflare
-
Delete the existing MX record
-
Select the funcation [Email]-[Email Routing]
-
You can use the Quick Start Guide to configure your email by clicking the button [开始使用]
-
创建自定义地址。自定义地址,即用来接受电子邮件的自定义地址,是基于你的域名的。目标地址,即希望转发至的目标地址,可以是你的 Gmail 或者 Outlook 地址。点击[创建并继续]进行下一步
建议使用 Gmail 或者 Outlook 作为目标地址。我测试了使用 Foxmail 作为目标地址,会出现邮件无法发送的情况。具体可查看20230619的"email send error.pdf"
-
验证目标地址。Cloudflare 会向你的目标地址发送一封验证邮件,点击链接完成验证
-
配置 DNS 记录。Cloudflare 会自动添加相关的 DNS 记录,无需手动添加。点击[自动添加记录],完成配置
在具体测试时,使用 Gmail 或者 Outlook 作为目标地址,等了很长时间(> 24h)才收到邮件。可能是因为 Cloudflare 部署路由需要时间。
Catch-all address. 配置 Catch-all 后,无论邮箱前缀是什么,所有发给该域名的邮件都会转发到指定目标地址。
Use Gmail to send emails
-
添加自定义地址为 Gmail 别名.[账号和导入]-[添加其他电子邮件地址]
邮箱名字会为发邮件的默认名,即发件人名称。
邮箱地址,为自定义地址。 -
SMTP 需要更改为 smtp.gmail.com
port 端口保持默认即可,如果需要变更协议,端口需要做相应变更
username 填写原本 Gmail 的用户名,即邮箱地址中除去 @gmail.com 之外的信息
password 需要使用谷歌应用密码配置页面获取的专属应用密码 -
如果上述信息填写成功,即可进入下一页面,自定义地址会收到一封验证邮件,完成即可成功配置。
收件人可以看到发件人是由你的 Gmail 代发的,而且还出现身份验证失败之类的危险提示(我测试没有提示身份验证失败,只是会显示代发)
Use Outlook to send emails
-
添加自定义地址为微软账户别名
-
在 Outlook 设置中,设置该自定义地址为默认地址
收件人可以看到发件人是由你的 Outlook 代发的
Troubleshooting
- 无法使用 Microsoft 365 的 Outlook 中 “个性化电子邮件地址” 功能。该功能在个人和家庭版中只支持在 GoDaddy 中注册的域名,只有在商业版中才支持在其他注册商注册的域名。 而且该功能将于2023年底停止添加。