如何为多个域设置Postfix SMTP

这是我在Stacks上的第一个问题。 我几乎每隔一天都会阅读很多解决问题的方法。 所以,感谢所有的贡献者。 我在这里是一个小菜,所以如果我做错了,请腾出一些空间。 我的问题是

我正在尝试将Postfix服务器设置为多个域名的仅SMTP主机。 我不允许远程连接我只是想能够使用我的cron脚本来发送各种域的电子邮件。 目前Postfix是默认安装,但我已经添加

myhostname=example.com 

现在问题是,如果我从[email protected]发送电子邮件在电子邮件标题(不是在发件人地址)显示的主机是example.com确切的标题是

 Received: from example.com 

我的地址是正确的。 对不起,但我真的不知道很多关于电子邮件服务器。 我的传入是由另一个托pipe服务提供商处理,我知道我需要添加一个反向DNS等所以请如果有人知道我该怎么做,所以所有的域名都有正确的DNS条目加上良好的后缀configuration。 我希望postfix使用与源地址相同的域名。 我只需要smtp,没有别的。

我search谷歌和堆栈,但没有回答完全问题,即使问题是类似的。

在此先感谢,我仍然RTFMing到处都是。

我也在我的mailog中得到这些错误。 我已经用MYDOMAIN和一个真正的系统用户名replace了一个真正有效的域名

 Feb 14 22:53:13 li222-89 postfix/smtpd[28433]: connect from localhost[127.0.0.1] Feb 14 22:53:13 li222-89 postfix/smtpd[28433]: 428FCA400C: client=localhost[127.0.0.1] Feb 14 22:53:13 li222-89 postfix/cleanup[28436]: 428FCA400C: message-id=<4d59f8a8-0ab4-4aee-b6e6-6f0c9389ad7c@> Feb 14 22:53:13 li222-89 postfix/qmgr[27293]: 428FCA400C: from=<[email protected]>, size=1047, nrcpt=1 (queue active) Feb 14 22:53:13 li222-89 postfix/smtpd[28433]: disconnect from localhost[127.0.0.1] Feb 14 22:53:13 li222-89 postfix/smtp[27755]: certificate verification failed for gmail-smtp-in.l.google.com: num=20:unable to get local issuer certificate Feb 14 22:53:13 li222-89 postfix/smtp[27755]: certificate verification failed for gmail-smtp-in.l.google.com: num=27:certificate not trusted Feb 14 22:53:13 li222-89 postfix/pickup[26953]: C3761A400D: uid=500 from=<USER> Feb 14 22:53:13 li222-89 postfix/cleanup[28436]: C3761A400D: message-id=<[email protected]> Feb 14 22:53:13 li222-89 postfix/qmgr[27293]: C3761A400D: from=<[email protected]>, size=3237, nrcpt=1 (queue active) Feb 14 22:53:14 li222-89 postfix/smtp[26830]: certificate verification failed for aspmx.l.google.com: num=20:unable to get local issuer certificate Feb 14 22:53:14 li222-89 postfix/smtp[26830]: certificate verification failed for aspmx.l.google.com: num=27:certificate not trusted Feb 14 22:53:15 li222-89 postfix/smtp[27755]: 428FCA400C: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[74.125.155.27]:25, delay=2.6, delays=0.02/0.02/0.66/1.9, dsn=2.0.0, status=sent (250 2.0.0 OK 1297741995 l9si6487318yhl.10) Feb 14 22:53:15 li222-89 postfix/qmgr[27293]: 428FCA400C: removed Feb 14 22:53:17 li222-89 postfix/smtp[26830]: C3761A400D: to=<[email protected]>, orig_to=<USER>, relay=aspmx.l.google.com[74.125.155.27]:25, delay=14, delays=11/0/0.44/3.1, dsn=5.1.1, status=bounced (host aspmx.l.google.com[74.125.155.27] said: 550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596 hj39si8560308ibb.50 (in reply to RCPT TO command)) Feb 14 22:53:17 li222-89 postfix/cleanup[28436]: 726DFA400C: message-id=<[email protected]> Feb 14 22:53:17 li222-89 postfix/qmgr[27293]: 726DFA400C: from=<>, size=5596, nrcpt=1 (queue active) Feb 14 22:53:17 li222-89 postfix/bounce[28222]: C3761A400D: sender non-delivery notification: 726DFA400C Feb 14 22:53:17 li222-89 postfix/qmgr[27293]: C3761A400D: removed Feb 14 22:53:17 li222-89 postfix/smtp[27755]: certificate verification failed for aspmx.l.google.com: num=20:unable to get local issuer certificate Feb 14 22:53:17 li222-89 postfix/smtp[27755]: certificate verification failed for aspmx.l.google.com: num=27:certificate not trusted Feb 14 22:53:21 li222-89 postfix/smtp[27755]: 726DFA400C: to=<[email protected]>, relay=aspmx.l.google.com[74.125.155.27]:25, delay=3.6, delays=0.02/0.01/0.44/3.1, dsn=5.1.1, status=bounced (host aspmx.l.google.com[74.125.155.27] said: 550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596 mu18si8573893ibb.7 (in reply to RCPT TO command)) Feb 14 22:53:21 li222-89 postfix/qmgr[27293]: 726DFA400C: removed 

显然,它试图发送电子邮件到一个Gmail帐户,但有些事是错的…真的不对。

我相信这是你想要的。

http://www.postfix.org/ADDRESS_REWRITING_README.html#generic

例:

 /etc/postfix/main.cf: smtp_generic_maps = hash:/etc/postfix/generic /etc/postfix/generic: [email protected] [email protected] [email protected] [email protected] @localdomain.local [email protected] 

所以,如果你已经安装和configuration了后缀。

打开main.cf并添加上面的通用映射设置。

然后打开通用文件并添加@ example.com @ example2.com或任何您所需的环境设置

这是一个散列文件,所以当你完成后运行postmap /etc/postfix/generic

然后重新启动后缀。

UPDATE

看起来这实际上是你以后的样子。

编辑主cf文件并更改这一行

 smtp inet n - n - - smtpd 

至:

 localhost:smtp inet n - n - - smtpd ipaddress1:smtp inet n - n - - smtpd ipaddress2:smtp inet n - n - - smtpd -o myhostname=hostname2 . . . ipaddressn:smtp inet n - n - - smtpd -o myhostname=hostname3 

重新启动后缀

显然这将需要您设置多个IP地址,每个域的一个,并build立反向DNS等我相信这是做到这一点的唯一方法。

 Feb 14 22:53:17 li222-89 postfix/smtp[27755]: certificate verification failed for aspmx.l.google.com: num=20:unable to get local issuer certificate Feb 14 22:53:17 li222-89 postfix/smtp[27755]: certificate verification failed for aspmx.l.google.com: num=27:certificate not trusted 

如果您尝试使用Gmail中继邮件,则有必要使用带有Postfix的TLS。首先,仔细检查Postfix是否configuration了SSL支持(例如,ldd至less应返回一行以libssl开头的行):

 $ whereis -b postfix postfix: /usr/sbin/postfix /etc/postfix /usr/libexec/postfix $ ldd /usr/sbin/postfix ... libssl.so.6 => /lib/libssl.so.6 (0x00111000) ... 

现在我们需要find你的服务器的CA根证书包,它通常是用openssl分发的。

 $ locate ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt 

编辑Postfix main.cf以包含TLS和SASL2以进行Gmail身份validation。

使用新的Gmail证书提供程序更新您的证书文件 。

 relayhost = smtp.gmail.com:587 # your FQDN, or default value below mydomain = example.com # your local machine name, or default value below myhostname = host.example.com myorigin = $myhostname # SASL smtpd_sasl_path = smtpd smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_type = cyrus smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous # TLS smtp_sasl_tls_security_options = noanonymous smtp_use_tls = yes smtp_tls_CAfile = /path/to/your/ca-bundle.crt smtp_sasl_tls_security_options = noanonymous 

后缀configuration“如何”(main.cf)

使用远程SMTP中继主机设置Postfix