广告

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

2017年1月8日星期日

Ubuntu - Postfix + Dovecot + MySql - Postfix 编

1. 修改 main.cf 和 master.cf

$ su
$ gedit /etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

append_dot_mydomain = no

readme_directory = no

# TLS parameters
#smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
#smtpd_use_tls=yes
#smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache 

smtpd_tls_cert_file=/etc/letsencrypt/live/member.dlinkddns.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/member.dlinkddns.com/privkey.pem
smtpd_use_tls=yes
smtpd_tls_auth_only = yes

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination

# smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

myhostname = member.dlinkddns.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
# mydestination = $myhostname, member.dlinkddns.com, localhost.dlinkddns.com, , localhost
mydestination = localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +

inet_interfaces = all
inet_protocols = ipv4

virtual_transport = lmtp:unix:private/dovecot-lmtp

virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf

$ gedit /etc/postfix/master.cf

这个文件还有其它设置, 你可以决定用哪一个端口

# 用端口 25
smtp      inet  n       -       y       -       -       smtpd

# 用端口 587
submission inet n       -       -       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

# 用端口 465
smtps     inet  n       -       y       -       -       smtpd

2. 重启

$ postfix reload
$ systemctl restart postfix


3. 其它

看有没邮件待寄
$ mailq

撤除等待寄出的邮件
$ postsuper -d <邮件ID>
$ postsuper -d ALL

让所有邮件现在寄出
$ postqueue -f

没有评论:

发表评论