Postfix relayhost with sasl PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Bart Dorlandt   
Friday, 18 December 2009 11:11

I use this configuration on every system which isn't my mailserver. It will have postfix installed locally and always has a connection to an smtp server. Even if you are in an other network (laptop user). So you don't have to do anything to meet your current provider. Also your locally installed mailclient can always point its smtp server to the localhost. Easy, right.

Installed packages:

apt-get install postfix libsasl2-2 libsasl2-modules 

Postfix configuration:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no

# TLS parameters
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtp_tls_received_header = yes
smtp_tls_loglevel = 1
tls_random_source = dev:/dev/urandom

# SASL
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myhostname = lan.bamweb.nl
myorigin = /etc/mailname
mydestination = localhost.bamweb.nl, localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only

As you can see this setup uses the Gmail SMTP server. See line which starts with "relayhost". Now we have to create the sasl_passwd file in /etc/postfix

Edit the file like this:

[smtp.gmail.com]:587 username:password
chown root:root /etc/postfix/sasl_passwd
chmod 700 /etc/postfix/sasl_passwd 

If you don't want to use gmail, change it in both files. Replace the username with your username (with @gmail.com) (or @domain.tld if you use google apps) and the password to your password in cleartext. Afterwards run postmap /etc/postfix/sasl_passwd. This will create the sasl_passwd.db file.

service postfix restart to restart your postfix service and enjoy your setup.

Ohhh... You might want to change the /etc/aliases if you not done so already.

 

 

 

 

 

Trackback(0)
Comments (0)Add Comment

Write comment - Name & Email obligated

busy
 


Related items: