User Tools

Site Tools


linux:mailconfigwithpostfix

This is an old revision of the document!


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

  • install
    yum remove sendmail
    yum install cyrus-sasl.x86_64 
    yum install postfix
  • set MTA default to postfix
      alternatives --set mta /usr/sbin/postfix
     

config and files

  • config files
    /etc/sasl2/smtpd.conf
    /etc/postfix/main.cf
  • log
    /var/log/maillog
  • check content of config
    postconf
  • check configs which change by user(none default)
    postconf -n

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”

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

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]

  • Check receiving mail base on maillog: /var/log/maillog
    • log for mailto [email protected]: status=sent (delivered to mailbox)
      May 22 05:39:52 mail postfix/smtpd[4228]: connect from mail-qg0-f43.google.com[209.85.192.43]
      May 22 05:39:52 mail postfix/smtpd[4228]: C968340900: client=mail-qg0-f43.google.com[209.85.192.43]
      May 22 05:39:53 mail postfix/cleanup[4232]: C968340900: message-id=<CADwQOAhT-WZ2wBRmXx0eDsJvTK5FtqauqryDDPgDCA7PYed3tw@mail.gmail.com>
      May 22 05:39:53 mail postfix/qmgr[4141]: C968340900: from=<[email protected]>, size=2268, nrcpt=1 (queue active)
      May 22 05:39:53 mail postfix/local[4233]: C968340900: to=<[email protected]>, relay=local, delay=0.74, delays=0.71/0.02/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
      May 22 05:39:53 mail postfix/qmgr[4141]: C968340900: removed
      May 22 05:39:53 mail postfix/smtpd[4228]: disconnect from mail-qg0-f43.google.com[209.85.192.43]
          
    • log for mailto [email protected]: sale@babies.vn: Recipient address rejected: User unknown in local recipient table
      May 22 05:43:13 mail postfix/anvil[4230]: statistics: max connection rate 1/60s for (smtp:209.85.192.43) at May 22 05:39:52
      May 22 05:43:13 mail postfix/anvil[4230]: statistics: max connection count 1 for (smtp:209.85.192.43) at May 22 05:39:52
      May 22 05:43:13 mail postfix/anvil[4230]: statistics: max cache size 1 at May 22 05:39:52
      May 22 05:43:58 mail postfix/smtpd[4247]: connect from mail-qc0-f179.google.com[209.85.216.179]
      May 22 05:43:59 mail postfix/smtpd[4247]: NOQUEUE: reject: RCPT from mail-qc0-f179.google.com[209.85.216.179]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail-qc0-f179.google.com>
      May 22 05:43:59 mail postfix/smtpd[4247]: disconnect from mail-qc0-f179.google.com[209.85.216.179]
  • check mail content received in “mail_spool_directory = /var/mail”
    cat /var/mail/root

    Or

    mail

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

With above steps, 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 root or [email protected](root 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
linux/mailconfigwithpostfix.1409966705.txt.gz · Last modified: 2022/10/29 16:15 (external edit)