2014年5月5日 星期一

install postfix and dovecot and redirect all mail to one account

1. install postfix, pcre and dovecot
# apt-get install postfix postfix-pcre
# apt-get install dovecot-core dovecot-imapd

2. confirm your dns mx record have one mx record for your mail server

3. modify your postfix configuration  for your environment
# vim /etc/postfix/main.cf

myhostname = mail.csp.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, $mydomain, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.16.0.0/16
always_bcc = tommy@csp.com.tw
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/

#head_checks
header_checks = pcre:/etc/postfix/header_checks

4.add new file /etc/postfix/header_checks
# vim /etc/postfix/header_checks
/TO:*@*/ REDIRECT check01@csp.com

5. check postfix setting and restart postfix
# postfix check
# /etc/init.d/postfix restart

6.modify /etc/dovecot/dovecot.conf
#vim /etc/dovecot/dovecot.conf
uncomment the lines

listen = *, ::
base_dir = /var/run/dovecot/
instance_name = dovecot
login_greeting = Dovecot ready.

7. change 10-auth.conf
#vim /etc/dovecot/conf.d/10-auth.conf
uncomment line and change the value
disable_plaintext_auth = no

8.change 10-master.conf
#vim /etc/dovecot/conf.d/10-master.conf
change contents within lines as below

service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
service lmtp {
  unix_listener lmtp {
    mode = 0666
  }

service auth {
   # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
}
auth_mechanisms = plain login

9. change 10-mail.conf
#vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir

10.change 20-imap.conf
#vim /etc/dovecot/conf.d/20-imap.conf
  imap_max_line_length = 64k
  mail_max_userip_connections = 10
  mail_plugins = $mail_plugins
  imap_logout_format = bytes=%i/%o
  imap_client_workarounds = tb-extra-mailbox-sep

11. restart the dovecot services.
# /etc/init.d/dovecot restart

沒有留言:

張貼留言