Table of Contents

refer: http://tecadmin.net/install-and-configure-postfix-on-centos-redhat/ email architecture: email system in linux
http://www.postfix.org/documentation.html
http://postfix.state-of-mind.de/patrick.koetter/smtpauth/sasldb_configuration.html
postfix slide show

Mailserver config

install and config postfix for sending and receiving mail

install

config and files

Basic config

Basic config for Sending and receiving mail with UNIX system accounts

What domain name to use in outbound mail

Edit /etc/postfix/main.cf:

myhostname = mail.babies.vn
mydomain = babies.vn
myorigin = $mydomain
inet_interfaces = all

The myorigin parameter specifies the domain that appears in mail that is posted on this machine. Follow this configuration, send mail as “user@$mydomain”

To secure the mailserver was can't be used by other server, you can config inet_interfaces to localhost:

inet_interfaces = localhost

what domains this machine will deliver locally

The mydestination parameter specifies what domains this machine will deliver locally, instead of forwarding to another machine.

Edit /etc/postfix/main.cf:

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

Active config in postfix

serivce postfix restart 
chkconfig postfix on

test sending and receiving mail

setup sendmail program: mailx

yum install mailx
yum install sendmail

test sending mail

mail anh.vochi@gmail.com
Subject: Test
This is a email test
#Ctr+D

test receiving mail

Using gmail [email protected] send to [email protected] and [email protected]

config user [email protected] can send mail to [email protected], base on UNIX system account

Default , we can send mail to [email protected]. But we can't send mail to [email protected]. Below are steps forward emails of [email protected] to sale UNIX system account(sale is UNIX system account)

config

[/etc/postfix/main.cf]

virtual_alias_maps = hash:/etc/postfix/virtual

[/etc/postfix/virtual]

[email protected] sale, [email protected], [email protected], [email protected]

Active changes in config

  1. run scripts below:
    postmap /etc/postfix/virtual
    #=> generate /etc/postfix/virtual.db
  2. reload postfix: /etc/init.d/postfix reload
  3. check config:
    postmap -q sale@babies.vn hash:/etc/postfix/virtual

Check Mail Server Storage(MSS) for Receiving Email which postfix support

postconf -a
cyrus
dovecot

Install and config Mail Server Storage with cyrus for Mail client connecting

               ------------------
Incoming Mail |--+     Postfix  <-----------| Outgoing Mail  |
                -|----------------                     |
                ||     LMTP      |                     |
                -|----------------                     |
                |+>    Cyrus    +----------------+     |
                |+>    Imapd    ||---->+         |     |
                -|--------------|-     |         |     |
                ||Authentication||    2|        1|     |
                |+<    SASL    <+|     v         ^     |
                ------------------     |Receiving|  |Sending|
                                           |           |
                                       +--------------------+
                                       |     Mail Client    |

Install cyrus

yum install cyrus-imapd.x86_64

config postfix connect with cyrus via lmtp(local mail transfer protocol)

config postfix

postconf -e "mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp"

config cyrus

[/etc/cyrus.conf]

lmtpunix      cmd="lmtpd" listen="/var/lib/imap/socket/lmtp" prefork=1

active changes in config

/etc/init.d/postfix restart
/etc/init.d/cyrus-imapd restart
chkconfig postfix on
chkconfig cyrus-imapd on

Config Cyrus-Imapd for domain and mail client authentication

[/etc/imapd.conf]

admins: cyrus cyrusadm