Setting up postfix for authenticated relay

From BubbaWiki
Revision as of 21:01, 5 December 2010 by Tor Krill (talk | contribs)
Jump to navigation Jump to search

This howto should work on both Bubba|TWO and Excito B3. But note that you should most likely only use this howto when your Bubba act as a Router in your lan. Security might be compromised otherwise. You have been warned .
This howto is a short description on howto configure Postfix to accept email for relay when the user authenticates himself. The usecase for this is to be able to use Bubba as an always available mailserver for sending emails when not at home. I myself use this setup and have all my laptops etc configured to send mail via my Bubba at home wherever i am in the world.

Postfix configuration

Start by logging into Bubba via ssh and become root.

Edit the file /etc/postfix/main.cf

Locate the lines with:

smtpd_recipient_restrictions =
 permit_mynetworks

And add the line:

 permit_sasl_authenticated

So the end result looks something like:

smtpd_recipient_restrictions =
 permit_mynetworks
 permit_sasl_authenticated
 reject_unauth_destination
 reject_unauth_pipelining
 reject_invalid_hostname
 reject_non_fqdn_sender
 reject_unknown_sender_domain
 reject_non_fqdn_recipient
 reject_unknown_recipient_domain
 reject_rbl_client dnsbl.njabl.org
 reject_rbl_client dnsbl.sorbs.net
 reject_rbl_client bl.spamcop.net
 permit

Then at the end of the file append:

smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_tls_auth_only = yes

Dovecot configuration

Edit the config file /etc/dovecot/dovecot.conf

Locate the section that starts with:

auth default {

and there  append the following:

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

Optional, let Postfix listen on another port than the default one

A big problem for most home users is that their ISP blocks all traffic on the default mailserver port (25) and thus our solution won't work. A workaround for this is to let Postfix, our mailserver, listen on an additional non standard port for connections.

To do this edit the file /etc/postfix/master.cf

Locate the line that says

smtp      inet  n       -       -       -       -       smtpd

and add the additional line below

20025     inet  n       -       -       -       -       smtpd

This tells Postfix to listen on both the standard smtp port (25) and also on 20025

Restart services

To finnish this up restart Dovecot and Postfix

/etc/init.d/dovecot restart

/etc/init.d/postfix restart

Open ports in the firewall

Finally to be able to use this solution outside your Lan you will have to open upp the corresponding ports in Bubbas firewall.

  • Log in to the web based admin UI as admin.
  • Select Administration
  • SelectNetwork
  • Select Firewall

If you only use the standard port make sure that "Email server (Port 25)" is On. If not click the checkbox and then click update.

Open smtp default port.png






If you decided to also use the extra port above you need to set this up manually. To do so select "Advanced firewall settings", check "Open B3 port" and enter the port you selected in "Public port".


Manually open smtp port.png


Then click "Update" and there should be one additional line in "User defined open / forwarded ports"


Manually opened smtp port.png

Final words

This should be it. Now you should be able to send emails from anywhere using the address and port of your Bubba and the user/password of your local user.

As an example, here is how you should configure Evolution to use this setup. Exchange server and username for your own values. And note how we append the port to use if we don't use default port 25.

Evolution smtp settings.png