Pages

Wednesday, October 19, 2011

Postfix SASL authentication with SMTP port 465


By default postfix SMTP works on 25 port. You can check this by following command with the output below:

#netstat -nat
tcp        0      0 0.0.0.0:25             0.0.0.0:*               LISTEN   


Here we will change the port to 465 with SASL authentication. It is useful technique to fight against spam. Users those travel here and there with their laptops need not to change their e-mail client software settings also.

Here is how we can do it.

1. Edit the file /etc/dovecot.conf and make sure your auth default section has the lines below.

auth default {
  socket listen {
    client {
 path = /var/spool/postfix/private/auth
 mode = 0660
 user = postfix
 group = postfix
    }
  }
  mechanisms = plain login
}


2. Edit /etc/postfix/main.cf, find the keys below and change its values as follows or add it at the bottom of the file if the key (the word before the = sign) cannot be found.
mynetworks = 127.0.0.0/8
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions =  permit_mynetworks, permit_sasl_authenticated, reject
broken_sasl_auth_clients = yes
smtpd_sender_restrictions = permit_sasl_authenticated


3. Edit /etc/postfix/master.cf
Put hash before the following line.
#smtp      inet  n       -       -       -       -       smtpd
Remove hash from the following lines.
smtps     inet  n       -       -       -       -       smtpd

-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject


Restart postfix service
Restart dovecot service

Now check the port again with the command:


#netstat -nat
tcp        0      0 0.0.0.0:465             0.0.0.0:*               LISTEN

Check more with telnet:

#telnet localhost 465


1 comment:

  1. Awesome post. I have been searching it for a long time. Here you have configured the SMTP port 465 but how can we use pop port 995? Can you pls post a doc regarding the issue. :)

    ReplyDelete