OpenSolaris Tutorials
Installing and Configuring OpenVPN in OpenSolaris
Deploying OpenSolaris In Amazon EC2
Installing Postfix and Dovecot Under OpenSolaris

Installing Postfix and Dovecot Under OpenSolaris

Configuring Postfix

Configuring postfix is handled through the files in /etc/postfix.

The first thing to do is wrap up the spamassassin configuration by integrating it into postfix. This is done by setting up a transport service in master.cf. The following should be placed at the begining of the file directly below the service type header.

spamfilt   unix  -       n       n       -       10      pipe
  flags=Rq user=filter argv=/usr/local/bin/spamchk -f ${sender} 
        -- ${recipient}

Also adjust the smtp line by appending '-o content_filter=spamfilt:dummy' to the end.

The meat of the configuration is stored in main.cf

# Location to store the mail queue
queue_directory = /opt/csw/var/spool/postfix
# Location of postfix binaries
command_directory = /opt/csw/sbin
# Location of daemon executables
daemon_directory = /opt/csw/libexec/postfix
# Owner of mail queue files
mail_owner = postfix
# mail server hostname
myhostname = mx1.higherpass.com
# Domain the mailserver resides in.  This is 
# normally the FQDN minus the local hostname.
mydomain = higherpass.com
# Origin of mail if one isn't present in the headers
myorigin = $mydomain
# local destination for mail
mydestination = localhost
# Code to give rejected mail
unknown_local_recipient_reject_code = 550
# Database for the alias
alias_database = hash:/etc/postfix/aliases
# Path to postfix sendmail binary.  Sendmail executable
# is included with most unix mailserver for compatibility.
sendmail_path = /opt/csw/sbin/sendmail
# Location of the newaliases command used to rebuild the
# aliases file
newaliases_path = /opt/csw/bin/newaliases
# Where to find the mailq command
mailq_path = /opt/csw/bin/mailq
# Group for mail submission and queue management
setgid_group = postdrop
#Directories to documentation
html_directory = /opt/csw/share/doc/postfix/html
manpage_directory = /opt/csw/share/man
sample_directory = /opt/csw/share/doc/postfix/samples
readme_directory = /opt/csw/share/doc/postfix/README_FILES
# Location of external file containing vhosts 1 per line.
# Alternatively vhosts could be listed comma separated.
virtual_mailbox_domains = /etc/postfix/vhosts.txt
# Base directory mailboxes are stores.
virtual_mailbox_base = /data/mail/vhosts
# The UID & GID mappings to write mail to the vhost mailboxes
# as.  These are the ones we created earlier.
virt_uid_maps = static:101
virt_gid_maps = static:102
# The minimun UID allowed.  Setting this to 100 or above prevents 
# any accidental writing as system users.
virtual_minimum_uid = 100
# Virtual mailbox mappings file
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
# Virtual aliases mappings
virtual_maps = hash:/etc/postfix/virtual
# Order to search files for delivery
local_recipient_maps = unix:passwd.byname $alias_maps $virtual_mailbox_maps
# Method to deliver mail of not found in the local password file or alias maps
fallback_transport = virtual
# Allow mail relaying for these domains
relay_domains = $transport_maps
# Alias maps file
alias_maps = hash:/etc/postfix/aliases
# Networks to listen on
inet_interfaces = all
# destinations this server is the final home for
mydestination = $myhostname, $mydomain
# Method to generate the mynetworks parameter
mynetworks_style = host
# Path to the mailbox relative to the local users homedir
home_mailbox = Maildir/
# Disable SMTP VRFY that can be used to harvest email addresses
disable_vrfy_command = yes
# SMTP mail destination access restrictions.
smptd_recipient_restrictions = permit_mynetworks, 
                               reject_rbl_client sbl.spamhaus.org,
                               reject_rbl_client bl.spamcop.net,	
                               reject_non_fqdn_sender,
                               reject_unknown_sender_domain,
                               reject_non_fqdn_recipient,
                               reject_unknown_recipient_domain,
                               reject_unauth_pipelining,
                               reject_unauth_destination, 
                               reject_unknown_client
# Give special treatment to owner-listname & listname-request
owner_request_special = no
# Setup SMTP authentication through dovecot.
smtpd_sasl_type = dovecot
smtpd_sasl_path = /opt/csw/var/spool/postfix/private/auth
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
# Enable and configure TLS security 
smtpd_tls_cert_file=/opt/csw/ssl/certs/dovecot.pem
smtpd_tls_key_file=/opt/csw/ssl/private/dovecot.pem
smtpd_use_tls=yes
tls_random_source = /dev/urandom
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

This is a very basic configuration file that should get postfix up and running. Take note of the smtpd_sasl_path and virtual_mailbox_base values, they'll be needed in the Dovecot configuration.

A basic /etc/postfix/aliases file.

MAILER-DAEMON:  postmaster
postmaster:     root
abuse:          postmaster
postfix:        root

List of vhosts hosted by Postfix /etc/postfix/vhosts.txt. This is the file from virtual_mailbox_domains in main.cf.

vhost1.dom
vhost2.dom
vhost3.dom

Mailbox list is stored in /etc/postfix/vmailbox. The left column is the email address and the right column is appended to virtual_mailbox_base. If the path ends with a trailing / the files are stored in qmails Maildir format, without the slash they're stored in standard mbox format.

# vhost1.dom
fake@vhost1.dom                    vhost1.dom/fake/
really.fake@vhost1.dom             vhost1.dom/really.fake/
 
 # vhost2.dom
 notreal@vhost2.dom                 vhost2.dom/notreal
 imaginary@vhost2.dom               vhost2.dom/imaginary

/etc/postfix/virtual stores the virtual aliases file. The left column holds the incoming address and the right the address to deliver to.

# vhost1.dom
postmaster@vhost1.dom              fake@vhost1.dom

Now that everything is configured the last thing to do with postfix is build the alias and mailbox databases. These are berkeley database files of the alias, virtual, and vmailbox files stored in /etc/postfix as aliases.db, virtual.db, and vmailbox.db.

# /opt/csw/sbin/postalias hash:/etc/postfix/aliases
# /opt/csw/sbin/postmap hash:/etc/postfix/virtual
# /opt/csw/sbin/postmap hash:/etc/postfix/vmailbox
Inatalling Postfix & Spamassassin <<  1 2 3  >> Installing and Configuring Dovecot
New Content