Configure Smarthost SMTP Authentication on Postfix

My machine at home cannot send email using port 25, end up I got to do smart host SMTP authentication on Port 587 means your machine will connect to your public mail server, and from your public mail server deliver the email to recipient. Let’s do some simple Smarthost SMTP authenication on Postfix. The example is Postfix on Linux Ubuntu server.

Create Authentication Password File For Postfix

Create a password file which require authentication on your mail server.


shell> vi /etc/postfix/smarthosts.conf

#mailserver username password
mail.example.com test 123123

Save the file and perform some simple permission settings.


shell> cd /etc/postfix
shell> chown root:root smarthosts.conf
shell> chmod 0600 smarthosts.conf
shell> postmap hash:$P

Now you have done with SMTP server authentication configuration file.

Configure Smart Relay on Postfix

Fire up Postfix’s main.cf config file


vi /etc/postfix/main.cf

Paste the config below on the bottom of the configuration


relayhost = mail.example.com:587
# smtp_sasl_auth_enable = yes
smtp_auth_enable = yes
# smtp_sasl_password_maps = hash:/etc/postfix/smarthosts.conf
smtp_password_maps = hash:/etc/postfix/smarthosts.conf

relayhost is the your server address and with port 587, in case your ISP is blocking port 25. You can use either plain password authentication or SASL authentication, depend on what type of authentication does your server support.

Save it and reload Postfix Service


shell> /etc/init.d/postfix reload

Perform the testing on your newly configured SMTP Smart Host Authentication


shell> echo 'Hello World' > /tmp/hello
shell> mail -s 'Hello World' test@example.com < /tmp/hello
shell> rm -f /tmp/hello

Check on the mail server log on delivery status.


shell> tail -F /var/log/mail.log
Mar 25 22:42:43 dummyserver postfix/pickup[6747]: 755A441202: uid=0 from=
Mar 25 22:42:43 dummyserver postfix/cleanup[6772]: 755A441202: message-id=<20100325144243.755A441202@dummyserver.WAG160N>
Mar 25 22:42:43 dummyserver postfix/qmgr[6748]: 755A441202: from=, size=305, nrcpt=1 (queue active)
Mar 25 22:42:54 dummyserver postfix/smtp[6775]: 755A441202: to=, relay=mail.example.com[203.222.222.222]:587, delay=11, delays=0.12/0.01/10/0.99, dsn=2.0.0, status=sent (250 OK id=1NuoGu-000PGq-6l)
Mar 25 22:42:54 dummyserver postfix/qmgr[6748]: 755A441202: removed

If the status is sent, it means your smart host is working well.

Related posts:

  1. Enable SMTP Port 587 on Exim Most of the ISP block port 25 for outgoing SMTP....
  2. Razor2 Error: No such file or directory report requires authentication While doing Spam Report on SpamAssassin, I came across this...
  3. Setup Sendmail Smart Relay in FreeBSD It’s good that to route all your outgoing email to...
  4. Configure NTP Server on FreeBSD Configure a NTP time server on FreeBSD is fairly easy....
  5. Configure Your Own screenrc file There are few shell scripts I need to run when...
  6. Exim: Restrict Authenticated Outgoing Email with Sender Domain Most of the outgoing SMTP server allowed the user to...
  7. Install and Configure mod_suphp or suphp on Plesk Server Plesk control panel comes with Media Temple DV package doesn’t...
  8. Configure IPV6 on Apple and Windows Do you have IPV6 network ready in your office? Lets...
  9. Check DNS Record with Dig Command Check DNS Record with Dig Command How do you find...
  10. MySQL Quick Installation on FreeBSD Quick installation of MySQL Database on FreeBSD Server. Make sure...

Leave a Reply