refer: http://tecadmin.net/install-and-configure-postfix-on-centos-redhat/ email architecture: [[linux:services#email_system_in_linux|email system in linux]]\\ http://www.postfix.org/documentation.html\\ http://postfix.state-of-mind.de/patrick.koetter/smtpauth/sasldb_configuration.html\\ {{:linux:postfix.ppt|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" 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 anh.vochi@gmail.com send to root@babies.vn and sale@babies.vn * Check receiving mail base on maillog: /var/log/maillog * log for mailto root@babies.vn: 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= May 22 05:39:53 mail postfix/qmgr[4141]: C968340900: from=, size=2268, nrcpt=1 (queue active) May 22 05:39:53 mail postfix/local[4233]: C968340900: to=, 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 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 : Recipient address rejected: User unknown in local recipient table; from= to= proto=ESMTP helo= 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 anh.vochi@gmail.com can send mail to sale@babies.vn, base on UNIX system account==== Default , we can send mail to root@babies.vn. But we can't send mail to sale@babies.vn. Below are steps forward emails of sale@babies.vn 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] sale@babies.vn sale, anh.vochi@gmail.com, tranvungoctram@gmail.com, trinhmigoi@yahoo.com === Active changes in config === - run scripts below: postmap /etc/postfix/virtual #=> generate /etc/postfix/virtual.db - reload postfix: /etc/init.d/postfix reload - check config: postmap -q sale@babies.vn hash:/etc/postfix/virtual - Using anh.vochi@gmail.com send mail to sale@babies.vn ==== 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