How to Configure SMTP authentication in Zimbra 8.x mail Server

When you need to route all outgoing mail through your ISP's MTA, and that MTA requires that you authenticate, certain settings in postfix are required.

Server Information
SMTP Rrelay server address: mail1.example.com
Username of SMTP Server: username@example.com
Password for repalay : Relay Server password

For SMTP Auth in ZCS 8.6
Below are the simple steps to setup SMTP auth server:
Create a file for relay_password file for authentication
# vim /opt/zimbra/conf/relay_password
mail.example.com shahzad@example.com:*********

Update file using portmap
#postmap /opt/zimbra/conf/relay_password

Backup below zmconfigd.cf file
#cp /opt/zimbra/conf/zmconfigd.cf /opt/zimbra/conf/zmconfigd.cf.org

Remove below parameter from file for duplicate entry

#vim /opt/zimbra/conf/zmconfigd.cf
smtp_sasl_password_maps
smtp_sasl_auth_enable
smtp_sasl_security_options
smtp_sasl_mechanism_filter
smtp_sasl_security_options=noanonymous

Backup postfix main config file

#cp -p /opt/zimbra/postfix/conf/main.cf /opt/zimbra/postfix/conf/main.cf.org

# vim /opt/zimbra/postfix/conf/main.cf        (Practical done on zimbra 8.6 Go to below and make your own line )
smtp_sasl_password_maps=texthash:/opt/zimbra/conf/relay_password
smtp_sasl_auth_enable=yes
smtp_cname_overrides_servername=no
sender_dependent_relayhost_maps=texthash:/opt/zimbra/postfix/conf/bysender
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = plain,login

Note: if you are using zimbra 8.5 or below version than change texthash to hash only.

Crate a file bysender and write your local domain name and smtp server address

# vim /opt/zimbra/postfix/conf/bysender
@example.com mail1.example.com

Now login with Zimbra user and restart zimbra service

#su – zimbra
$postfix reload

Or,
$zmcontrol restart

Change settings in DNS

Open DNS Zone file and create A record for SMTP server
mail1 IN A IP_Address-of-SMTP-Server

Restart DNS Service
#service named restart

Check MX record
#host –t mx example.com
example.com mail is handled by 0 mail1.example.com.

Now, send a test mail and check.
$ tail -f /var/log/zimbra.log
Mar 24 07:07:31 server postfix/smtp[7903]: 5D85AC250E: to=, relay=127.0.0.1[127.0.0.1]:10032, delay=146, delays=0.36/0.06/24/122, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 68FF3C24E4)
Mar 24 07:08:11 server postfix/smtp[8799]: 68FF3C24E4: to=, relay=mail1.example.com[41.52.119.111]:25, delay=44, delays=0.85/1.1/21/21, dsn=2.0.0, status=sent (250 OK id=1aip2m-0000Qf-Vp)
Mar 24 07:08:11 server postfix/qmgr[29484]: 68FF3C24E4: removed