My VPS provider (Slicehost) doesn't provide an SMTP server. I use Google Apps to send and receive mail for my domains, but I want to be able to programmatically send e-mail.
我的VPS提供程序(Slicehost)不提供SMTP服务器。我使用Google Apps为我的域发送和接收邮件,但我希望能够以编程方式发送电子邮件。
I've been Googling this issue on and off for many months, and I just can't seem to get a clear picture of what I need to do. Do I just need an MTA like postfix? Do I configure it as a "satellite", or an "internet" site? Do I need to make any DNS changes? If I want to programmatically receive e-mail someday, are there any configuration options I should be careful about tinkering with? Also, if my VPS host did provide an SMTP server, what wouldn't I need to do, that I'm doing now?
我一直在谷歌搜索这个问题好几个月,我似乎无法清楚地了解我需要做什么。我只需要像postfix这样的MTA吗?我将其配置为“卫星”或“互联网”网站吗?我是否需要进行任何DNS更改?如果我想有一天以编程方式接收电子邮件,是否有任何配置选项我应该小心修补?另外,如果我的VPS主机确实提供了一个SMTP服务器,我现在要做的不是我需要做什么?
Thank you!
Edit: A quick synopsis of my findings:
编辑:我的发现的简要概述:
- Update
/etc/hosts
and/etc/hostname
to reflect the FQDN (for example,mail.domain.com
orsub.domain.com
instead ofslicename
)- Reboot and verify with
hostname -f
使用主机名-f重新启动并验证
- Reboot and verify with
- Set up reverse DNS (which is owned by whoever owns the IP pool) to point at the same FQDN
- Check that the RDNS has propogated with
dig -x server.ip.address
检查RDNS是否已使用dig -x server.ip.address传播
- Check that the RDNS has propogated with
-
sudo aptitude install postfix telnet mailx
- Use internet site setting
- Set FQDN to whatever was chosen above
使用网站设置
将FQDN设置为上面选择的任何内容
- Test with
mail whateveryouremailis@gmail.com
更新/ etc / hosts和/ etc / hostname以反映FQDN(例如,mail.domain.com或sub.domain.com而不是slicename)使用主机名重新启动并验证-f
设置反向DNS(由拥有IP池的任何人拥有)指向相同的FQDN检查RDNS已经使用dig -x server.ip.address传播
sudo aptitude install postfix telnet mailx使用网站设置将FQDN设置为上面选择的任何内容
用邮件测试whateveryouremailis@gmail.com
4 个解决方案
#1
3
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.
你看过这里,在我看来有很多信息可以开始。我发现mail-server-slice-setup非常有用。
#2
2
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.)
根据我的经验,当电子邮件提供商检查垃圾邮件时,他们会检查除内容之外的5个主要内容:(当我说域名时,我指的是发件人电子邮件地址的域名。)
- "A" record (IP) of the domain name exists
- MX records of the domain name exist
- 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)
- 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.)
- The IP segment of the server is not a blacklisted segment.
存在域名的“A”记录(IP)
存在域名的MX记录
存在发送者IP地址的PTR记录(反向查找)(有时,我认为还要检查PTR记录是否与原始域具有相同的A记录)
该域的SPF记录与IP号匹配(这是允许发送该域的电子邮件的IP号列表。虽然这对于垃圾邮件过滤来说是一个很好的解决方案,但这不是官方记录,因此并不总是检查。查看SPF设置向导。)
服务器的IP段不是列入黑名单的段。
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.
第五个问题对我来说是一个问题。显然,Hotmail,Gmail,Yahoo等电子邮件提供商会丢弃来自广泛使用的服务器提供商(如Amazon EC2)的所有传入电子邮件。在这种情况下,根本无法保证所有外发电子邮件的发送,因此您必须从列入黑名单的部分之外的其他某些SMTP服务器中继所有外发电子邮件。最简单的方法是配置Postfix(或您正在使用的任何MTA)以自动中继所有电子邮件。如果你做一些谷歌搜索,你可以找到很多关于此的文章。
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.
如果不是这样,那么您只需要一个简单的MTA,如Postfix,只要上面列出的所有必要的DNS记录都配置正确,您就可以轻松发送电子邮件。
#3
1
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 sender@example.com; 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.
假设您正在发送来自sender@example.com的电子邮件;然后(正如Murat Ayfer所说),您需要确保允许您的主机根据example.com的SPF记录发送邮件。 (这可能是也可能不是由IP地址配置 - 有关详细信息,请参阅SPF站点。)如果您负责example.com域,那么这应该不是问题。被列为域名的可接受发件人是您的电子邮件通过的重要一步。
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.
接下来你需要担心的是如何处理退回的电子邮件。如果其他主机收到example.com的电子邮件(即其他地方的MX记录点),那么主要是其他人的问题。 (但请注意,例如,由于语法无效的电子邮件地址,您的应用程序必须准备好在主机上的邮件服务器的SMTP会话期间出现故障。)但是如果您决定接收example.com上的邮件您的主机,然后您需要担心处理重试邮件,退回邮件,双重退回邮件,以及许多其他常规邮件服务器管理。有关处理Web应用程序中未传递的电子邮件的一些信息可能会有所帮助,但我也建议您在Postfix或您决定使用的任何邮件服务器上获得一本好书。
#4
0
Just install something like postfix as "internet site" and you'll be able to send mails directly from your VPS
只需安装像postfix这样的“互联网站点”,你就可以直接从你的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
它应该使用默认设置,但建议还阅读一些文档/操作方法以正确保护它
#1
3
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.
你看过这里,在我看来有很多信息可以开始。我发现mail-server-slice-setup非常有用。
#2
2
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.)
根据我的经验,当电子邮件提供商检查垃圾邮件时,他们会检查除内容之外的5个主要内容:(当我说域名时,我指的是发件人电子邮件地址的域名。)
- "A" record (IP) of the domain name exists
- MX records of the domain name exist
- 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)
- 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.)
- The IP segment of the server is not a blacklisted segment.
存在域名的“A”记录(IP)
存在域名的MX记录
存在发送者IP地址的PTR记录(反向查找)(有时,我认为还要检查PTR记录是否与原始域具有相同的A记录)
该域的SPF记录与IP号匹配(这是允许发送该域的电子邮件的IP号列表。虽然这对于垃圾邮件过滤来说是一个很好的解决方案,但这不是官方记录,因此并不总是检查。查看SPF设置向导。)
服务器的IP段不是列入黑名单的段。
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.
第五个问题对我来说是一个问题。显然,Hotmail,Gmail,Yahoo等电子邮件提供商会丢弃来自广泛使用的服务器提供商(如Amazon EC2)的所有传入电子邮件。在这种情况下,根本无法保证所有外发电子邮件的发送,因此您必须从列入黑名单的部分之外的其他某些SMTP服务器中继所有外发电子邮件。最简单的方法是配置Postfix(或您正在使用的任何MTA)以自动中继所有电子邮件。如果你做一些谷歌搜索,你可以找到很多关于此的文章。
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.
如果不是这样,那么您只需要一个简单的MTA,如Postfix,只要上面列出的所有必要的DNS记录都配置正确,您就可以轻松发送电子邮件。
#3
1
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 sender@example.com; 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.
假设您正在发送来自sender@example.com的电子邮件;然后(正如Murat Ayfer所说),您需要确保允许您的主机根据example.com的SPF记录发送邮件。 (这可能是也可能不是由IP地址配置 - 有关详细信息,请参阅SPF站点。)如果您负责example.com域,那么这应该不是问题。被列为域名的可接受发件人是您的电子邮件通过的重要一步。
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.
接下来你需要担心的是如何处理退回的电子邮件。如果其他主机收到example.com的电子邮件(即其他地方的MX记录点),那么主要是其他人的问题。 (但请注意,例如,由于语法无效的电子邮件地址,您的应用程序必须准备好在主机上的邮件服务器的SMTP会话期间出现故障。)但是如果您决定接收example.com上的邮件您的主机,然后您需要担心处理重试邮件,退回邮件,双重退回邮件,以及许多其他常规邮件服务器管理。有关处理Web应用程序中未传递的电子邮件的一些信息可能会有所帮助,但我也建议您在Postfix或您决定使用的任何邮件服务器上获得一本好书。
#4
0
Just install something like postfix as "internet site" and you'll be able to send mails directly from your VPS
只需安装像postfix这样的“互联网站点”,你就可以直接从你的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
它应该使用默认设置,但建议还阅读一些文档/操作方法以正确保护它