我已经使用 postfix、dovecot 和 spamassasin 在 ubuntu 16.04 上设置了一个邮件服务器,我可以登录到 gmail 和 apple mail。以下形式的电子邮件[电子邮件保护]工作正常,传入和传出
例如使用虚拟域的电子邮件[电子邮件保护]只能发送电子邮件,不能从其他主机接收电子邮件。但它们可以相互发送和接收
这是我的 /etc/postfix/main.conf
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
smtpd_tls_cert_file=/etc/letsencrypt/live/mydomain.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/mydomain.com/privkey.pem
smtpd_use_tls=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 = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
emails to the local mailboxes.
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
smtp_generic_maps = hash:/etc/postfix/generic
以下是我的 Dovecot 配置
auth_mechanisms = plain login
mail_location = maildir:/var/mail/vhosts/%d/%n
mail_privileged_group = mail
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
special_use = \Trash
}
prefix =
}
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
protocols = imap lmtp pop3
service auth-worker {
user = vmail
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0666
user = postfix
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
user = dovecot
}
service imap-login {
inet_listener imap {
port = 0
}
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
ssl = required
ssl_cert = </etc/letsencrypt/live/mydomain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mydomain.com/privkey.pem
ssl_prefer_server_ciphers = yes
ssl_protocols = !SSLv2 !SSLv3
userdb {
args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n
driver = static
}
netstat -ntlp 的输出是
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 1264/dovecot
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 1264/dovecot
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1248/mysqld
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 4604/master
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 1264/dovecot
tcp 0 0 127.0.0.1:783 0.0.0.0:* LISTEN 2660/spamassassin.p
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1237/sshd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 4604/master
tcp6 0 0 :::993 :::* LISTEN 1264/dovecot
tcp6 0 0 :::995 :::* LISTEN 1264/dovecot
tcp6 0 0 :::587 :::* LISTEN 4604/master
tcp6 0 0 :::110 :::* LISTEN 1264/dovecot
tcp6 0 0 ::1:783 :::* LISTEN 2660/spamassassin.p
tcp6 0 0 :::80 :::* LISTEN 1453/apache2
tcp6 0 0 :::22 :::* LISTEN 1237/sshd
tcp6 0 0 :::25 :::* LISTEN 4604/master
tcp6 0 0 :::443 :::* LISTEN 1453/apache2
以下是我的日志文件的尾部
Aug 6 11:41:49 abstractclassa postfix/postfix-script[4386]: warning: group or other writable: /usr/lib/postfix/./libpostfix-master.so.1
Aug 6 11:41:49 abstractclassa postfix/postfix-script[4387]: warning: group or other writable: /usr/lib/postfix/./sbin/lmtp
Aug 6 11:41:49 abstractclassa postfix/postfix-script[4388]: warning: group or other writable: /usr/lib/postfix/sbin/./lmtp
Aug 6 11:46:32 abstractclassa dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=168.167.4.2, lip=172.31.33.89, mpid=4431, TLS, session=<ypg$
Aug 6 11:46:37 abstractclassa dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=168.167.4.2, lip=172.31.33.89, mpid=4434, TLS, session=<g$
Aug 6 11:46:38 abstractclassa dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=168.167.4.2, lip=172.31.33.89, mpid=4435, TLS, session=<i$
Aug 6 11:49:10 abstractclassa dovecot: imap([email protected]): Connection closed in=227 out=4529
Aug 6 11:49:10 abstractclassa dovecot: imap([email protected]): Connection closed in=75 out=1685
Aug 6 11:49:10 abstractclassa dovecot: imap([email protected]): Connection closed in=75 out=1683
Aug 6 11:49:21 abstractclassa postfix[4476]: Postfix is running with backwards-compatible default settings
Aug 6 11:49:21 abstractclassa postfix[4476]: See http://www.postfix.org/COMPATIBILITY_README.html for details
Aug 6 11:49:21 abstractclassa postfix[4476]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
Aug 6 11:49:21 abstractclassa postfix/master[3765]: terminating on signal 15
Aug 6 11:49:21 abstractclassa postfix[4567]: Postfix is running with backwards-compatible default settings
Aug 6 11:49:21 abstractclassa postfix[4567]: See http://www.postfix.org/COMPATIBILITY_README.html for details
Aug 6 11:49:21 abstractclassa postfix[4567]: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
Aug 6 11:49:22 abstractclassa postfix/master[4604]: daemon started -- version 3.1.0, configuration /etc/postfix
Aug 6 11:49:30 abstractclassa dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=168.167.4.2, lip=172.31.33.89, mpid=4611, TLS, session=<9TX$
Aug 6 11:49:37 abstractclassa dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=168.167.4.2, lip=172.31.33.89, mpid=4614, TLS, session=<S$
Aug 6 11:49:37 abstractclassa dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=168.167.4.2, lip=172.31.33.89, mpid=4615, TLS, session=<M$
Aug 6 11:52:51 abstractclassa dovecot: imap([email protected]): Connection closed in=380 out=7376
Aug 6 11:52:51 abstractclassa dovecot: imap([email protected]): Connection closed in=1575 out=14486
Aug 6 11:52:51 abstractclassa dovecot: imap([email protected]): Connection closed in=2015 out=31191
答案1
好吧,错误确实出在我身上,没有经过适当的研究就做了一些事情,我不知道你放在 MySQL 表中的虚拟域必须是真实存在的域才能正常工作
因此我使用了不存在的域名,而 Gmail 尝试找到它们来发送电子邮件,但找不到它们。
否则我的电子邮件服务器运行正常