这可能是我在 Linux 上遇到过的最困难的挑战。我从来没有想到发送和接收无处不在的电子邮件是如此复杂!
按照本教程使用 Postfix、Dovecot、MySQL 和 RoundCube 在 CentOS 8 上设置邮件服务器,在之前的尝试失败后,我一直在尝试创建邮件服务器,因为这似乎可以创建一个完整的电子邮件套件。我已经仔细检查了所有步骤,包括 dovecot、postfix、php、mysql 和 RoundCube 的安装和配置以及教程,但我仍然无法登录 RoundCube。在设置中,我使用 mysql 来存储邮件用户。数据库和表以及用户和所有内容都已正确设置。错误显示:
连接存储服务器失败。
我当前的Roundcube config.inc.php如下:
/* Local configuration for Roundcube Webmail */
$config['db_dsnw'] = 'mysql://roundcube:PassWord@localhost/roundcubemail';
$config['default_host'] = 'ssl://mail.example.com';
$config['support_url'] = '';
$config['default_port'] = 143;
$config['des_key'] = 'AQI98mYP4asPYRIGW6dm4Pj5';
$config['plugins'] = array();
$config['language'] = 'en_US';
$config['spellcheck_engine'] = 'pspell';
//-----------
// SMTP
$config['smtp_server'] = 'ssl://mail.example.com';
$config['smtp_port'] = 587;
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['smtp_auth_type'] = 'LOGIN';
$config['debug_level'] = 1;
$config['smtp_debug'] = true;
$config['plugins'] = array('virtuser_query');
$config['virtuser_query'] = "SELECT Email FROM postfix_accounts.accounts_table WHERE Email = '%u'";
系统上postfix和dovecot的当前状态:
● postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2020-05-17 02:27:38 EDT; 2h 30min ago
Process: 969 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
Process: 1012 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
Process: 1010 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
Process: 1006 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
Main PID: 1087 (master)
Tasks: 7 (limit: 24008)
Memory: 26.1M
CGroup: /system.slice/postfix.service
├─ 1087 /usr/libexec/postfix/master -w
├─ 1089 qmgr -l -t unix -u
├─ 1393 tlsmgr -l -t unix -u
├─ 1394 anvil -l -t unix -u
├─ 7982 smtpd -n submission -t inet -u -o stress= -s 3 -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=no -o smtpd_tls_auth_only=yes -o smtpd_reject_unlisted_recipient=no -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject -o smtpd_relay_restrictions=permit_sasl_authenticated -o milter_macro_daemon_name=ORIGINATINGmixed -o smtpd_reject_unlisted_recipient=no
├─13355 pickup -l -t unix -u
└─19712 smtpd -n smtp -t inet -u -o stress= -s 3
May 17 04:57:33 mail.example.com postfix/submission/smtpd[7982]: connect from unknown[45.142.195.14]
May 17 04:57:35 mail.example.com postfix/smtpd[19712]: disconnect from unknown[45.142.195.13] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
May 17 04:57:44 mail.example.com postfix/submission/smtpd[7982]: disconnect from unknown[45.142.195.14] ehlo=1 auth=0/1 rset=0/1 quit=1 commands=2/4
May 17 04:57:59 mail.example.com postfix/submission/smtpd[7982]: connect from unknown[45.142.195.14]
May 17 04:58:01 mail.example.com postfix/anvil[1394]: statistics: max connection rate 3/60s for (submission:45.142.195.14) at May 17 04:49:05
May 17 04:58:01 mail.example.com postfix/anvil[1394]: statistics: max connection count 1 for (submission:45.142.195.14) at May 17 04:48:12
May 17 04:58:01 mail.example.com postfix/anvil[1394]: statistics: max cache size 2 at May 17 04:49:26
May 17 04:58:10 mail.example.com postfix/submission/smtpd[7982]: disconnect from unknown[45.142.195.14] ehlo=1 auth=0/1 rset=0/1 quit=1 commands=2/4
May 17 04:58:25 mail.example.com postfix/submission/smtpd[7982]: connect from unknown[45.142.195.14]
May 17 04:58:36 mail.example.com postfix/submission/smtpd[7982]: disconnect from unknown[45.142.195.14] ehlo=1 auth=0/1 rset=0/1 quit=1 commands=2/4
● dovecot.service - Dovecot IMAP/POP3 email server
Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-05-16 14:24:57 EDT; 14h ago
Docs: man:dovecot(1)
http://wiki2.dovecot.org/
Process: 16278 ExecStop=/usr/bin/doveadm stop (code=exited, status=0/SUCCESS)
Process: 16322 ExecStart=/usr/sbin/dovecot (code=exited, status=0/SUCCESS)
Process: 16300 ExecStartPre=/usr/libexec/dovecot/prestartscript (code=exited, status=0/SUCCESS)
Main PID: 16349 (dovecot)
Tasks: 5 (limit: 24008)
Memory: 6.8M
CGroup: /system.slice/dovecot.service
├─16349 /usr/sbin/dovecot
├─16373 dovecot/anvil
├─16374 dovecot/log
├─16376 dovecot/config
└─28350 dovecot/auth
May 17 02:05:48 mail.example.com dovecot[16374]: pop3-login: Disconnected: Too many bad commands (no auth attempts in 0 secs): user=<>, rip=51.178.78.153, lip=178.238.237.150, session=<G9d61tGlquozsk6Z>
May 17 02:38:47 mail.example.com dovecot[16374]: pop3-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=45.136.108.68, lip=178.238.237.150, session=<nkZmTNKllActiGxE>
May 17 02:48:21 mail.example.com dovecot[16374]: imap-login: Aborted login (no auth attempts in 7 secs): user=<>, rip=66.240.219.146, lip=178.238.237.150, session=<1QGqbtKlqKZC8NuS>
May 17 02:48:27 mail.example.com dovecot[16374]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=66.240.219.146, lip=178.238.237.150, TLS, session=<b2IFb9Kl8rBC8NuS>
May 17 02:48:28 mail.example.com dovecot[16374]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=66.240.219.146, lip=178.238.237.150, TLS handshaking: SSL_accept() failed: error:142090FC:SSL routines:tls_early_post_process_client_hello:unknown protocol, session=<psUVb9Kl9LFC8NuS>
May 17 02:51:01 mail.example.com dovecot[16374]: imap-login: Disconnected (no auth attempts in 156 secs): user=<>, rip=66.240.219.146, lip=178.238.237.150, TLS: Disconnected, session=<J9o0eNKlgK9C8NuS>
May 17 04:02:06 mail.example.com dovecot[16374]: pop3-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=45.136.108.23, lip=178.238.237.150, session=<knxgdtOlaActiGwX>
May 17 04:17:12 mail.example.com dovecot[16374]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=127.0.0.1, lip=127.0.0.1, TLS handshaking: SSL_accept() failed: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca: SSL alert number 48, session=</91qrNOlDJB/AAAB>
May 17 04:17:35 mail.example.com dovecot[16374]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=127.0.0.1, lip=127.0.0.1, TLS handshaking: SSL_accept() failed: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca: SSL alert number 48, session=<5ILKrdOlDpB/AAAB>
May 17 04:24:38 mail.example.com dovecot[16374]: pop3-login: Disconnected (tried to use disallowed plaintext auth): user=<[email protected]>, rip=185.234.219.224, lip=178.238.237.150, session=<GZ32xtOl+re56tvg>
我真的希望能有一个解决方案来解决这个问题,而不是必须插入那么多螺母和螺栓才能启动和运行一个简单的邮件服务器!
有人知道问题是什么吗?
附言:
由于某种原因 SSL 无法正常工作,因此我在 RoundCube 配置中将 default_host 更改为 localhost,并在 /etc/postfix/master.cf 中注释了以下两行
# -o smtpd_tls_security_level=encrypt
# -o smtpd_tls_auth_only=yes
现在,RoundCube 可以正常工作了,尽管我似乎无法从 Gmail 接收电子邮件。尽管我已为 postfix 指定了密钥和 crt 文件,但由于某种原因它无法正常工作:
smtpd_tls_key_file = /etc/postfix/ssl/mykey.key ##SSL Key
smtpd_tls_cert_file = /etc/postfix/ssl/mycertificate.crt
所以,这就是我现在所拥有的一切!我希望有人能给出比禁用 SSL 更好的解决方案。
答案1
这可能对您有用。请尝试删除配置文件中的授权凭据,然后点击发送。
$config['smtp_user'] = '';
$config['smtp_pass'] = '';