I would like some support in order to get my Postfix configuration working with my Zoho email account. What I am trying to do is to send a message from my contact form in http://www.g3eo.com/#!/page_Contacts to my Zoho email account. For that I configured Postfix in my ubuntu box in this way (based on http://emanuelesantanche.com/configuring-postfix-to-relay-email-through-zoho-mail/):
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = noappend_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
In my website contact form things seem to be working fine, you can test it by sending a message with the Firebug open (press F12) in the Network tab. After sending the email it appears this message "mail sent" in the response tab. However, that message does not reach my email address in my Zoho email account. After checking the /var/log/mail.log
it shows:
Jul 4 21:46:42 xxxxxxxxxx postfix/qmgr[9100]: D9B2E5E0292:
from=, size=549, nrcpt=1 (queue active)
Jul 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 authentication failed; server smtp.zoho.com[165.254.168.48] said: 535 Authentication Failed)
I understand that the authentication problem is because my message could get into the Zoho smtp server, so it was rejected, not sure if it is the case. I would appreciate if someone could help to understand what is going on here and how to fix it.
My contact form uses the following files:
- http://www.g3eo.com/extras/js/forms.js
and http://www.g3eo.com/extras/bin/MailHandler.php (see below)
if($_POST['name']!='nope'){
$messageBody .= 'Visitor: ' . $_POST["name"] . '
' . "\n";
$messageBody .= '
' . "\n";
}
if($_POST['email']!='nope'){
$messageBody .= 'Email Address: ' . $_POST['email'] . '
' . "\n";
$messageBody .= '
' . "\n";
}else{
$headers = '';
}
if($_POST['state']!='nope'){
$messageBody .= 'State: ' . $_POST['state'] . '
' . "\n";
$messageBody .= '
' . "\n";
}
if($_POST['phone']!='nope'){
$messageBody .= 'Phone Number: ' . $_POST['phone'] . '
' . "\n";
$messageBody .= '
' . "\n";
}
if($_POST['fax']!='nope'){
$messageBody .= 'Fax Number: ' . $_POST['fax'] . '
' . "\n";
$messageBody .= '
' . "\n";
}
if($_POST['message']!='nope'){
$messageBody .= 'Message: ' . $_POST['message'] . '
' . "\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";
}
EDIT#1:
after changing /etc/postfix/password
from smtp.zoho.com:587
to [smtp.zoho.com]
I receiced in /var/log/mail.log
:
Jul 4 23:46:24 xxxxxxxxxx postfix/pickup[2926]: 8BC545E0261:
uid=33 from=
Jul 4 23:46:24 xxxxxxxxxx postfix/cleanup[2933]: 8BC545E0261:
message-id=<20160705044624.8BC545E0261@xxxxxxxxxx>
Jul 4 23:46:24 xxxxxxxxxx postfix/qmgr[2927]: 8BC545E0261:
from=, size=588, nrcpt=1 (queue active)
Jul 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 (host
smtp.zoho.com[165.254.168.48] said: 530 5.5.1 Authentication Required.
(in reply to MAIL FROM command))
Jul 4 23:46:27 xxxxxxxxxx postfix/cleanup[2933]: 098835E026E:
message-id=<20160705044627.098835E026E@xxxxxxxxxx>
Jul 4 23:46:27 xxxxxxxxxx postfix/bounce[2932]: 8BC545E0261:
sender non-delivery notification: 098835E026E
Jul 4 23:46:27 xxxxxxxxxx postfix/qmgr[2927]: 098835E026E:
from=<>, size=2494, nrcpt=1 (queue active)
Jul 4 23:46:27 xxxxxxxxxx postfix/qmgr[2927]: 8BC545E0261:
removed
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 (delivered to mailbox)
Jul 4 23:46:27 xxxxxxxxxx postfix/qmgr[2927]: 098835E026E:
removed
is 587
the problem here?
Answer
Solved!, here the solution:
I had in /etc/postfix/smtp_header_checks
:
/^From:.*/ REPLACE From: LOCALHOST System ;
and now I have:
/^From:.*/ REPLACE From:info@g3eo.com
check that I had to delete the semi-colon at the end as well as the whole "LOCALHOST SYTEM" plus blank spaces, and that was it!! hope this helps someone else out there, cheers!
No comments:
Post a Comment