如何设置 Ubuntu VPS 来发送外发邮件?

发布于 2024-07-07 07:48:21 字数 1941 浏览 9 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

当梦初醒 2024-07-14 07:48:22

根据我的经验,当电子邮件提供商检查垃圾邮件时,他们会检查内容以外的 5 个主要内容:
(当我说域时,我指的是发件人电子邮件地址的域。)

  1. 域名的“A”记录 (IP) 存在 域名的
  2. MX 记录 存在
  3. 发件人 IP 地址的 PTR 记录(反向查找)存在(有时,我认为还会检查PTR记录是否与原始域具有相同的A记录)
  4. 该域的SPF记录与IP号码匹配(这是允许发送该域的电子邮件的IP号码列表虽然这对于垃圾邮件过滤来说是一个很好的解决方案,但这不是官方记录,因此并不总是检查它。 ">查看 SPF 设置向导。)
  5. 服务器的 IP 网段不是黑名单网段。

第五个问题对我来说是个问题。 显然,Hotmail、Gmail、Yahoo 等电子邮件提供商会丢弃来自 Amazon EC2 等广泛使用的服务器提供商的所有传入电子邮件。 在这种情况下,根本无法保证所有外发电子邮件的送达,因此您必须中继来自黑名单网段之外的其他 SMTP 服务器的所有外发电子邮件。 最简单的方法是将 Postfix(或您使用的任何 MTA)配置为自动中继所有电子邮件。 如果你用谷歌搜索一下,你可以找到很多关于这方面的文章。

如果不是这种情况,那么您只需要一个像 Postfix 这样的简单 MTA,只要正确配置上面列出的所有必需的 DNS 记录,您发送电子邮件应该不会有任何问题。

To my experience, when email providers check for spams, they check 5 main things other than content:
(When I say domain, I'm referring to the domain of the sender's email address.)

  1. "A" record (IP) of the domain name exists
  2. MX records of the domain name exist
  3. PTR record (Reverse lookup) of the sender's IP address exists (Sometimes, I think it is also checked to see if the PTR record has the same A record as the original domain)
  4. SPF record of that domain matches the IP number (This is a list of IP numbers allowed to send emails of that domain. Although this would be a great solution for spam filtering, this is not an official record, so it is not always checked. Check out the SPF setup wizard.)
  5. The IP segment of the server is not a blacklisted segment.

The fifth one is the one that was a problem for me. Apparently email providers such as Hotmail, Gmail, Yahoo drop all incoming email from widely used server providers such as Amazon EC2. In that case, there's simply no way to guarantee the delivery of all outgoing emails, so you would have to relay all outgoing email from some other SMTP server outside the blacklisted segment. The easiest way to do this is configuring Postfix (or whatever MTA you're using) to automatically relay all emails. You can find plenty of articles on this if you do some googling.

If that is not the case, then all you need is a simple MTA like Postfix, as long as all the necessary DNS records listed above are configured properly, you should have no trouble sending emails.

街角迷惘 2024-07-14 07:48:22

其他答案提供了有关发送电子邮件机制的信息,但您需要考虑的一件事是您将使用什么发件人地址,以及如何处理退回邮件。

假设您要从 [电子邮件受保护] 发送电子邮件; 然后(正如 Murat Ayfer 指出的那样)您需要确保您的主机可以根据 example.com 的 SPF 记录发送邮件。 (这可能会或可能不会通过 IP 地址进行配置 - 请参阅 SPF 站点 了解更多详细信息。)如果您负责 example.com 域,那么这应该不是问题。 被列为域可接受的发件人是您的电子邮件顺利通过的重要一步。

接下来您需要担心的是如何处理退回的电子邮件。 如果其他主机收到 example.com 的电子邮件(即其他地方的 MX 记录),那么这主要是其他人的问题。 (但请注意,您的应用程序必须做好在与主机上的邮件服务器进行 SMTP 会话期间发生故障的准备,例如,由于语法上无效的电子邮件地址而导致的故障。)但是,如果您决定接收 example.com 上的邮件如果您的主机是您的主机,那么您需要担心处理重试消息、退回消息、双重退回消息以及许多其他常规邮件服务器管理。 有一些关于在网络应用程序中处理未送达的电子邮件的信息可能会有所帮助,但我也建议买一本关于 Postfix 或您决定使用的任何邮件服务器的好书。

Other answers have provided information about the mechanics of sending email, but one thing you need to consider is what sender address you're going to use, and how you're going to deal with bounce messages.

Let's say you're sending emails from [email protected]; then (as Murat Ayfer noted) you need to make sure that your host is allowed to send mail according to example.com's SPF record. (This may or may not be configured by IP address -- see the SPF site for more details.) If you're in charge of the example.com domain, then this shouldn't be a problem. Being listed as an acceptable sender for the domain is an important step towards your emails getting through.

The next thing you need to worry about is how to deal with bounced emails. If some other host receives emails for example.com (i.e. the MX record points elsewhere), then it's mainly someone else's problem. (Note however that your application has to be prepared for a failure during the SMTP session to the mailserver on your host, due to syntactically invalid email addresses, for example.) But if you decide that you'll receive mail for example.com on your host, then you need to worry about dealing with retry messages, bounce messages, double bounce messages, and a whole lot of other general mail server administration. There's some info on handling undelivered emails in web applications which might be helpful, but I also suggest getting a good book on Postfix or whatever mail server you decide to use.

—━☆沉默づ 2024-07-14 07:48:22

只需安装像 postfix 这样的东西作为“互联网站点”,您就可以直接从您的 VPS 发送邮件,

它应该使用默认设置,但建议您还阅读一些文档/操作方法以正确保护它

Just install something like postfix as "internet site" and you'll be able to send mails directly from your VPS

it should work with default settings but it would be recommended to also read a few docs/how-to's to secure it properly

在巴黎塔顶看东京樱花 2024-07-14 07:48:21

您是否看过这里,在我看来,有很多信息可以开始。 我发现 mail-server-slice-setup内容丰富。

Have you looked here, seems to me that there is plenty of information to get started. I found mail-server-slice-setup to be quite informative.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文