为了让我的 Postfix 配置与我的 Zoho 电子邮件帐户一起工作,我需要一些支持。我想要做的是从我在http://www.g3eo.com/#!/page_Contacts的联系表格中向我的 Zoho 电子邮件帐户发送一条消息。为此,我以这种方式在我的 ubuntu 框中配置了 Postfix(基于http://emanuelesantanche.com/configuring-postfix-to-relay-email-through-zoho-mail/):
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no
append_dot_mydomain = no readme_directory = no mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = loopback-only inet_protocols = all # TLS parameters smtp_tls_policy_maps = hash:/etc/postfix/tls_policy smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtp_header_checks = pcre:/etc/postfix/smtp_header_checks myhostname = xxxxxxxxxx alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = xxxxxxxxxx, localhost.com, localhost relayhost = smtp.zoho.com:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/password #smtp_sasl_security_options = smtp_generic_maps = hash:/etc/postfix/generic smtp_sasl_security_options = noanonymous smtp_always_send_ehlo = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtpd_relay_restrictions = permit_mynetworks,permit_sasl_authenticated,defer_unauth_destination
在我的网站联系表单中,事情似乎运行良好,您可以通过在“网络”选项卡中打开 Firebug(按 F12)发送消息来测试它。发送电子邮件后,它会在回复选项卡中显示此消息“已发送邮件”。但是,该消息没有到达我在 Zoho 电子邮件帐户中的电子邮件地址。检查后/var/log/mail.log
显示:
7 月 4 日 21:46:42 xxxxxxxxxx postfix/qmgr[9100]: D9B2E5E0292: from=, size=549, nrcpt=1 (queue active)
7 月 4 日 21:46:45 xxxxxxxxxx postfix/smtp[27824]: D9B2E5E0292: to=, relay=smtp.zoho.com[165.254.168.48]:587, delay=114224, delays=114222/0.01/2.6/0, dsn =4.0.0, status=deferred (SASL 认证失败;服务器 smtp.zoho.com[165.254.168.48] 说: 535 Authentication Failed)
我了解身份验证问题是因为我的消息可能会进入 Zoho smtp 服务器,所以它被拒绝了,不确定是不是这样。如果有人可以帮助了解这里发生了什么以及如何解决它,我将不胜感激。
我的联系表格使用以下文件: - http://www.g3eo.com/extras/js/forms.js
和http://www.g3eo.com/extras/bin/MailHandler.php(见下文)
if($_POST['name']!='nope'){ $messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['email']!='nope'){ $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; }else{ $headers = ''; } if($_POST['state']!='nope'){ $messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['phone']!='nope'){ $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['fax']!='nope'){ $messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['message']!='nope'){ $messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n"; } if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; }
编辑#1:
/etc/postfix/password
从更改为 后smtp.zoho.com:587
,[smtp.zoho.com]
我收到了/var/log/mail.log
:
7 月 4 日 23:46:24 xxxxxxxxxx 后缀/拾取 [2926]: 8BC545E0261: uid=33 from= Jul 4 23:46:24 xxxxxxxxxx 后缀/清理[2933]: 8BC545E0261: message-id=<20160705044624.8BC545E0261@xxxxxxxxxx>
7 月 4 日 23:46:24 xxxxxxxxxx postfix/qmgr[2927]: 8BC545E0261: from=, size=588, nrcpt=1 (queue active)
7 月 4 日 23:46:26 xxxxxxxxxx postfix/smtp[2930]: 8BC545E0261: to=, relay=smtp.zoho.com[165.254.168.48]:587, delay=2.1, delays=0.13/0/1.8/0.16, dsn =5.5.1,status=bounced(主机 smtp.zoho.com[165.254.168.48] 说:530 5.5.1 Authentication Required。(回复 MAIL FROM 命令))
7 月 4 日 23:46:27 xxxxxxxxxx 后缀/清理 [2933]: 098835E026E: message-id=<20160705044627.098835E026E@xxxxxxxxxx>
7 月 4 日 23:46:27 xxxxxxxxxx 后缀/退回 [2932]:8BC545E0261:发件人未送达通知:098835E026E
7 月 4 日 23:46:27 xxxxxxxxxx postfix/qmgr[2927]: 098835E026E: from=<>, size=2494, nrcpt=1 (queue active)
7 月 4 日 23:46:27 xxxxxxxxxx 后缀/qmgr[2927]:8BC545E0261:已删除
Jul 4 23:46:27 xxxxxxxxxx postfix/local[2934]: 098835E026E: to=, relay=local, delay=0.09, delays=0.05/0/0/0.04, dsn=2.0.0, status=sent (发送到邮箱)
7 月 4 日 23:46:27 xxxxxxxxxx 后缀/qmgr[2927]:098835E026E:已删除
问题587
在这里吗?
解决了!,这里的解决方案:
我有
/etc/postfix/smtp_header_checks
:现在我有:
检查我是否必须删除最后的分号以及整个“本地主机系统”加上空格,就是这样!希望这对其他人有帮助,干杯!