Postfix Logo

Postfix with SASL Authentication

To be able to have your server send logs, notifications etc. to a real email address, chances are email will not be accepted from your local host as most DSL and cable lines have dynamic IP addresses. So you will have to relay via your ISPs mailserver, most likely using SASL authentication.

Install postfix MTA

sudo aptitude install postfix

Configure as smarthost and enter the fqd of your ISP’s SMTP server.

sudo nano /etc/postfix/sasl_passwd

This file must contain thelogin credentials for the SMTP host. Normally the email account credentials.

smtp.isp.com username:password
sudo chown root:root /etc/postfix/sasl_passwd && sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap hash:/etc/postfix/sasl_passwd

To map local users to a real email address we use a mapping table.

sudo nano /etc/postfix/sender_canonical

In this file specify all mappings in the form of

username username@my.domain.name

Create the db file by running

sudo postmap hash:/etc/postfix/sender_canonical

I also had to add the following two parameters in main.cf

inet_protocols = ipv4
append_dot_mydomain = yes

The complete postfix config file will look something like this:

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.

myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)

biff = no

# appending .domain is the MUA's job.

append_dot_mydomain = yes

# Uncomment the next line to generate "delayed mail" warnings

#delay_warning_time = 4h

readme_directory = no

# TLS parameters

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

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for

# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

myhostname = my.domain.name

mydomain = domain.name

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

sender_canonical_maps = hash:/etc/postfix/sender_canonical

mydestination = my.domain.name, my, localhost.localdomain, localhost

relayhost = smtp.isp.com

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

mailbox_size_limit = 0

recipient_delimiter = +

inet_interfaces = all

#if ipv6 is not configured
inet_protocols = ipv4

# SASL SUPPORT FOR SERVERS

#

# The following options set parameters needed by Postfix to enable

# Cyrus-SASL support for authentication of mail servers.

#

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

smtp_sasl_security_options = noanonymous

Edit /etc/aliases to map mail users to real email

sudo nano /etc/aliases

As such:

# See man 5 aliases for format
postmaster:    root
www-data: root
root: realuser@example.com

Finally run

sudo newaliases

After all changes are made to the postfix config file run

sudo postfix reload

In order to be able to send email install the mailutils package

sudo aptitude install mailutils

You should now have a running mailsystem to send email to outside addresses.

Reference

Comments 3

  1. Pingback: Haswell MythTV Server for 2015 | osiris

  2. Pingback: Mythbuntu 14.04.1 on Haswell Machine | osiris

  3. Pingback: Mythbuntu on Ubuntu 14.10 | osiris

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.