在CentOS 6.4上针对Gmail的Postfix SMTP中继服务器

我目前正尝试在CentOS 6.4机器上使用Postfix设置SMTP中继服务器到Gmail,所以我可以从我的PHP脚本发送电子邮件。

我按照这个教程,但是当我试图做一个

sendmail alex.extranomical@gmail.com

输出:

tail -f / var / log / maillog

Apr 16 01:25:54 ext-server-dev01 postfix/cleanup[3646]: 86C2D3C05B0: message-id=<[email protected]> Apr 16 01:25:54 ext-server-dev01 postfix/qmgr[3643]: 86C2D3C05B0: from=<[email protected]>, size=297, nrcpt=1 (queue active) Apr 16 01:25:56 ext-server-dev01 postfix/smtp[3648]: 86C2D3C05B0: to=<[email protected]>, relay=smtp.gmail.com[173.194.79.108]:587, delay=4.8, delays=3.1/0.04/1.5/0.23, dsn=5.5.1, status=bounced (host smtp.gmail.com[173.194.79.108] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 qh4sm3305629pac.8 - gsmtp (in reply to MAIL FROM command)) 

这是我的main.cfconfiguration,我尝试了一些不同的选项,但似乎没有任何工作:

 alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 html_directory = no inet_interfaces = localhost inet_protocols = ipv4 mail_owner = postfix mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man mydestination = $myhostname, localhost.$mydomain, localhost myhostname = host.local.domain myorigin = $myhostname newaliases_path = /usr/bin/newaliases.postfix queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES relayhost = [smtp.gmail.com]:587 sample_directory = /usr/share/doc/postfix-2.6.6/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_sasl_tls_security_options = noanonymous smtp_sasl_type = cyrus smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt smtp_use_tls = yes smtpd_sasl_path = smtpd unknown_local_recipient_reject_code = 550 

/ etc / postfix / sasl_passwd文件(sasl_passwd&sasl_passwd.db)中,我得到了以下内容(删除了真实密码,并用“password”replace):

[smtp.google.com]:587 [email protected]:密码

要创buildsasl_passwd.db文件,我通过运行这个命令来完成这个任务:

postmap哈希:/ etc / postfix / sasl_passwd

有没有人知道我为什么似乎无法从服务器发送电子邮件?

亲切的问候亚历克斯

 # telnet smtp.gmail.com 587 Trying 173.194.70.108... Connected to smtp.gmail.com. Escape character is '^]'. 220 mx.google.com ESMTP h52sm28987766eez.3 - gsmtp ehlo localhost 250-mx.google.com at your service, [46.4.15.52] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250 CHUNKING 

没有auth可用。 您必须在端口25/587上使用STARTTLS或在端口465上使用SSL / TLS

 smtp_tls_policy_maps = hash:/etc/postfix/tls_policy smtp_tls_security_level = secure smtp_tls_mandatory_protocols = TLSv1 smtp_tls_mandatory_ciphers = high smtp_tls_secure_cert_match = nexthop 

/等/后缀/ tls_policy

 gmail.com encrypt protocols=TLSv1 ciphers=high 

/等/后缀/ sasl_passwd

 [smtp.gmail.com]:587 [email protected]:password 

在maillog中会像下面这样

 # swaks -s 127.0.0.1 --helo localhost --to [email protected] --from [email protected] # cat /var/log/maillog | grep 283AC120834 Sep 21 15:43:55 mail postfix/smtpd[28486]: 283AC120834: client=localhost[127.0.0.1] Sep 21 15:43:55 mail postfix/cleanup[28489]: 283AC120834: message-id=<[email protected]> Sep 21 15:43:55 mail postfix/qmgr[28481]: 283AC120834: from=<[email protected]>, size=449, nrcpt=1 (queue active) Sep 21 15:43:56 mail postfix/smtp[28490]: 283AC120834: to=<[email protected]>, relay=smtp.gmail.com[173.194.70.108]:587, delay=1.7, delays=0.01/0/0.64/1, dsn=2.0.0, status=sent (250 2.0.0 OK 1379792594 y47sm29107298eew.12 - gsmtp) Sep 21 15:43:56 mail postfix/qmgr[28481]: 283AC120834: removed