跳至正文
首页 » 部署poste.io邮件服务器

部署poste.io邮件服务器

poste.io 是一个方便部署的全功能邮件服务器。借助 docker ,仅需几分钟就可以完成一个邮件服务器的部署。用户数据和配置独立存储,方便进行备份与迁移。同时,poste.io 包含了防毒、防垃圾邮件措施,保护用户安全。 本文将介绍 部署poste.io邮件服务器 。

部署poste.io

1 poste.io安装

首先安装docker,然后启动docker服务。docker可以虚拟出预设好的一个空间给poste.io使用,大大减少了软件对系统的要求。

curl -fsSL http://get.docker.com/ | sh
systemctl start docker
systemctl enable docker

然后使用下面代码安装poste的docker容器。因为我希望博客和邮件使用同一个服务器,所以我将修改了http和https的端口,否则会和博客服务器冲突。如果独占服务器,可以去掉倒数二、三行。

docker run \
     --net=host \
     -v /etc/localtime:/etc/localtime:ro \
     -v /srv/poste/data:/data \
     --name "poste" \
     -h "mail.beekc.top" \
     -e "HTTP_PORT=81"\
     -e "HTTPS_PORT=444"\
     -t analogic/poste.io

2 DNS设置

poste.io安装后就可以通过ip地址访问邮件系统了。如果系统使用域名来收发邮件,那么还需要在DNS中增加两项记录。

3 通过反向代理使博客和邮件在同一个服务器上运行

默认情况下,两个系统都是通过80和443进行访问的。为了解决冲突,在第一节中修改了poste.io的端口到81和444。下面将使用vhosts、反向代理实现不同域名解析到不同的端口上。

首先需要/etc/httpd/conf/httpd.conf中取消以下行前的注释,使apache加载代理相关模块和vhosts的配置文件。

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Include conf/extra/httpd-vhosts.conf

接下来修改 /etc/httpd/conf/extra/httpd-vhosts.conf,在文件最后加入以下行。

<VirtualHost *:80>
    ServerName mail.beekc.top
    ProxyPass / http://localhost:81/
    ProxyPassReverse / http://localhost:81/
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =mail.beekc.top
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>
    ServerName mail.beekc.top:443
    ProxyPass / https://localhost:444/
    ProxyPassReverse / https://localhost:444/
    SSLEngine on
    SSLProxyEngine on
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
    ServerAlias mail.beekc.top
    SSLCertificateFile /etc/letsencrypt/live/mail.beekc.top/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/mail.beekc.top/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

4 关于25号端口

25号端口使发送邮件(SMTP)使用的端口。为了防止垃圾邮件,大多数VPS(包括阿里、腾讯、Vultr等)提供商都封禁了25号端口的使用。Vultr在帮助文档中写到如果需要使用可以联系客服开启。于是我尝试了下竟然真的成功了,还是很开心的。这里也粘出来作为纪念,也给其他遇到问题的人作为参考。

 i want to use TCP port 25 (SMTP), could you help me unlock it 
Hello,
Thank you for contacting us. We have received your SMTP Unblock request. However before we can remove this block, we must verify additional information. 
Please reply to this ticket with the following information:
1. The business name and organization URL(s) under which you offer services.
2. Describe, in as much detail as possible, the nature of the emails you intend to send.
3. The volume of email that you plan to deliver on a daily/monthly basis.
We need to know this information to make an informed decision regarding your account settings. 
Please let us know if you have any questions.
Thank you,
 thank you for your reply. i am a student of ******* (url) and building website for our lab (url). i just want to use SMTP to send signing-up mails to users.
it will only be used 6~7 times a day.
Thank you for the information! 
We have removed the default SMTP block on your account. 
Please restart any active instances via https://my.vultr.com for the change to take effect (restarting via the server itself _will_not_ work).
Please keep in mind that marketing and bulk email is restricted in our platform. For reference, our ANTI-SPAM policy is listed here: https://www.vultr.com/legal/antispam_policy.php
Our team is here and always happy to help if you need anything else. 
Best Regards,

5 容器自启动

可以在创建容器时增加选项–restart=always。如果已经创建完容器,可以使用下面命令更新选项。

docker update --restart=always poste

6 参考

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注