0

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 = 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

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 .= '<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";
  }

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?

  • Isn't it just rejecting your authentication? – Julie Pelletier Jul 5 '16 at 3:48
  • not really sure but it could be, how can I fix that? – Gery Jul 5 '16 at 4:27
  • Check /etc/postfix/password to make sure it contains [smtp.zoho.com] yourusername:yourpassword, that you ran postmap hash:/etc/postfix/passwords and restarted the postfix service. – Julie Pelletier Jul 5 '16 at 4:37
  • thanks already did it but the message does not reach my email account yet, please take a look at my first edit (EDIT#1), is the 587 the problem here? – Gery Jul 5 '16 at 4:54
0

Solved!, here the solution:

I had in /etc/postfix/smtp_header_checks:

/^From:.*/ REPLACE From: LOCALHOST System <info@g3eo.com>;

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.