admin';?>

首页 / 电子邮件系统

Postfix + Dovecot + Mysql 搭建自己的电子邮件系统

By admin  •  2022-01-01 13:15:44  •  729次点击
永久外链: https://i.otherhill.com/static/df4575916ac111ec87ea2089845721cb.html

7. Email收发测试

1. 使用日志.

sudo tail -f /var/log/maillog
sudo tail -f /var/log/dovecot.log

2.email serve host上,测试smtp能否正常发送电邮.

端口映射总览:
vps               remote-stunnel                                      local-stunnel     my-house
25         25    <-> myhouse.otherhill.com:1026          1026 <->4144       4144
2525     2525 <-> myhouse.otherhill.com:1026          1026 <->4144       4144
465       465   <-> myhouse.otherhill.com:1466          1466 <->4148       4148
587       587   <-> myhouse.otherhill.com:1588          1588 <->4149       4149
143       143   <-> myhouse.otherhill.com:1144          1144 <->4147       4147
993       993   <-> myhouse.otherhill.com:1994          1994 <->4150       4150
995       995   <-> myhouse.otherhill.com:1996          1996 <->4151       4151

[root@mail log]# telnet mail.otherhill.com 4144
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 mail.otherhill.com ESMTP Postfix
ehlo otherhill.com
250-mail.otherhill.com
250-PIPELINING
250-SIZE 10485760
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 CHUNKING
MAIL FROM:<i@otherhill.com>
250 2.1.0 Ok
RCPT TO:<xxxx@163.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Test message

This is a test.
疑难问题
.
250 2.0.0 Ok: queued as 8A981122D66

500 5.5.2 Error: bad syntax
quit
221 2.0.0 Bye
Connection closed by foreign host.

telnet到本机的方式,测试发电邮, 你要修改/etc/hosts文件, 加入
192.168.1.xxx  otherhill.com
192.168.1.xxx mail.otherhill.com
改成你自己的域名及本机IP.
正常的话,可以给自己的163邮箱发邮件, 如果失败, 查看/var/log/maillog, 和/var/log/dovecot.log的日志输出,查看发送失败的原因.

 ctrl+] 退出telnet

4146是pop3端口
[root@localhost dovecot]# telnet 127.0.0.1 4146
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
+OK Dovecot ready.
USER i@otherhill.com
+OK
PASS abcdefg
+OK Logged in.
LIST
+OK 0 messages:
.
quit

4147是imap的143端口
[root@mail log]# telnet mail.otherhill.com  4147
Trying 127.0.0.1...
Connected to mail.otherhill.com.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
1 login i@otherhill.com abcdefg
1 OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE LITERAL+ NOTIFY] Logged in
1 logout
* BYE Logging out
1 OK Logout completed (0.001 + 0.000 secs).
Connection closed by foreign host.

4151是pops的995端口
[root@localhost dovecot]# openssl s_client -connect 127.0.0.1:4151
。。。
+OK Dovecot ready.
USER i@otherhill.com
+OK
PASS abcdefg
+OK Logged in.
list
+OK 0 messages:
.
quit

查看tls证书
openssl s_client -starttls smtp -connect 127.0.0.1:4144

openssl s_client -starttls smtp -ign_eof -crlf -connect 127.0.0.1:4149


查看邮箱配额
doveadm quota get -u i@otherhill.com

查询数据库查询是否正常
postmap -c /opt/tsMail/etc/postfix  -q otherhill.com mysql:/opt/tsMail/etc/postfix/mysql-virtual-mailbox-domains.cf
sudo ln -s /opt/tsMail/etc/postfix /etc/postfix
postmap -q otherhill.com mysql:/opt/tsMail/etc/postfix/mysql-virtual-mailbox-domains.cf
postmap -q i@otherhill.com mysql:/opt/tsMail/etc/postfix/mysql-virtual-mailbox-maps.cf
postmap -q i@otherhill.com mysql:/opt/tsMail/etc/postfix/mysql-virtual-alias-maps.cf


一切正常的话,就可以用第三方电邮客户端,尝试连接与登录了,记住要还原之前/etc/hosts中的修改,即注释掉
#192.168.1.xxx  otherhill.com
#192.168.1.xxx mail.otherhill.com

然后打开ThundBird, 测试登录:


thundbird默认会连143和587端口,你也可以指定连接指定端口,如: 993端口




收件人帐号,可以是 https://mail.163.com , 或者是 https://yopmail.com 这类一次性免注册邮箱.

至此,大功告成!

我们把 postfix + dovecot + mysql + php + nginx + stunnel + openssl  全部打包好,做成安装程序, 并让电邮系统运行于chroot囚笼环境之中,以保障原有系统安全不受电邮影响.
我们的电邮安装程序, 支持在所有主流Linux x64系统上安装与运行. 其实就是将以上所有配置,用程序来自动化完成.


上一篇:   Email服务器反代

   

下一篇:   电邮安装程序





0 回复 | 直到2022-05-27 23:08添加回复

回复

最近更新

私信给我
生成图片 生成二维码 生成密码
清空