广告

本站里的文章大部分经过自行整理与测试

2017年1月8日星期日

Ubuntu - Postfix + Dovecot + MySql - Dovecot 编

要修改的文件共 7个

1. dovecot.conf

$ su
$ gedit /etc/dovecot/dovecot.conf

!include_try /usr/share/dovecot/protocols.d/*.protocol

protocols = imap lmtp pop3

#listen = *, ::

dict {
  #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
  #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext
}

!include conf.d/*.conf
!include_try local.conf

2. dovecot-sql.conf.ext

$ gedit /etc/dovecot/dovecot-sql.conf.ext

driver = mysql

connect = host=member.dlinkddns.com dbname=servermail user=root password=password

default_pass_scheme = SHA512-CRYPT

password_query = SELECT email as user, password FROM virtual_users WHERE email='%u';

3. $ gedit /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = yes

auth_mechanisms = plain login

#!include auth-deny.conf.ext
#!include auth-master.conf.ext

#!include auth-system.conf.ext
!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext

#!include auth-static.conf.ext

4. 10-mail.conf

$ gedit /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:/var/mail/vhosts/%d/%n

namespace inbox {
}

mail_privileged_group = mail

5. 10-master.conf

$ gedit /etc/dovecot/conf.d/10-master.conf

service imap-login {
  inet_listener imap {
    port = 143
    #port = 0
  }
  inet_listener imaps {
    #port = 993
    #ssl = yes
  }
}

service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
    port = 995
    #ssl = yes
  }
}

service lmtp {
   unix_listener /var/spool/postfix/private/dovecot-lmtp {
  mode = 0600
  user = postfix
  group = postfix
   }
}

service imap {
  # Max. number of IMAP processes (connections)
  #process_limit = 1024
}

service pop3 {
  # Max. number of POP3 processes (connections)
  #process_limit = 1024
}

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

  unix_listener auth-userdb {
    #mode = 0666
    #user = 
    #group = 
    mode = 0600
    user = vmail
  }

  user = dovecot
}

service auth-worker {
  #user = root
  user = vmail
}

service dict {
  unix_listener dict {
    #mode = 0600
    #user = 
    #group = 
  }

}

6. 15-mailboxes.conf

$ gedit /etc/dovecot/conf.d/15-mailboxes.conf

namespace inbox {

  # 没有这个设置就无法用如 thunderbird 这类 POP / IMAP 客户端软件
  inbox = yes

  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Trash {
    special_use = \Trash
  }

  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
}

7. 10-ssl.conf

$ gedit /etc/dovecot/conf.d/10-ssl.conf

ssl = required

ssl_cert = </etc/letsencrypt/live/jasonmun.dlinkddns.com/cert.pem
ssl_key = </etc/letsencrypt/live/jasonmun.dlinkddns.com/privkey.pem
ssl_ca = </etc/letsencrypt/live/jasonmun.dlinkddns.com/fullchain.pem

8. 重启

$ systemctl restart dovecot

9. 其它

$ ls -ld /var/mail
drwxrwsr-x 3 root vmail 4096 Jan 24 21:23 /var/mail

$ mkdir -p /var/mail/vhosts/member.dlinkddns.com

$ groupadd -g 5000 vmail 
$ useradd -g vmail -u 5000 vmail -d /var/mail

$ chown -R vmail:vmail /var/mail

$ chown -R vmail:dovecot /etc/dovecot
$ chmod -R o-rwx /etc/dovecot

10. Thunderbird (POP3 /IMAP) 邮箱设置

Username / Email address: boy@member.dlinkddns.com
Password: password
Server hostname (POP3 / IMAP): member.dlinkddns.com
SSL: STARTTLS
Authentication: Normal password

没有评论:

发表评论