使用Forsaken Mail搭建一个临时邮箱系统,即收即毁

/ 0评 / 0

说明:Forsaken Mail是一个临时邮箱系统,可以供任何人接受邮件,即收即毁,支持自定义邮箱地址前缀,这里就说下DockerNPM两种安装教程,任选一种即可,有兴趣或者有需求的可以玩玩。

截图

请输入图片描述
请输入图片描述

需求

1、VPS需要开启25端口,这个直接发工单要主机商开启。
2、域名解析,如果你想邮件地址格式都为*@xx.com的形式,则为xx.com设置MX记录,需要添加以下2条解析记录。

<span class="hljs-selector-id"><span class="com">#MX</span></span><span class="com">记录</span>
<span class="hljs-selector-tag"><span class="pln">xx</span></span><span class="hljs-selector-class"><span class="pun">.</span><span class="pln">com</span></span> <span class="hljs-selector-tag"><span class="pln">MX</span></span> <span class="lit">10</span> <span class="hljs-selector-tag"><span class="pln">mx</span></span><span class="hljs-selector-class"><span class="pun">.</span><span class="pln">xx</span></span><span class="hljs-selector-class"><span class="pun">.</span><span class="pln">com</span></span>
<span class="hljs-selector-id"><span class="com">#A</span></span><span class="com">记录 </span>
<span class="hljs-selector-tag"><span class="pln">mx</span></span><span class="hljs-selector-class"><span class="pun">.</span><span class="pln">xx</span></span><span class="hljs-selector-class"><span class="pun">.</span><span class="pln">com</span></span> <span class="hljs-selector-tag"><span class="pln">A</span></span> <span class="pun">服务器</span><span class="hljs-selector-tag"><span class="pln">IP</span></span>

NPM安装

Github地址:https://github.com/denghongcai/forsaken-mail

1、安装NPM

<span class="hljs-comment"><span class="com">#Debian/Ubuntu系统</span></span>
<span class="hljs-attribute"><span class="pln">curl</span></span> <span class="pun">-</span><span class="pln">sL https</span><span class="pun">:</span><span class="com">//deb.nodesource.com/setup_10.x | bash -</span><span class="pln">
apt</span><span class="pun">-</span><span class="kwd">get</span><span class="pln"> install </span><span class="pun">-</span><span class="pln">y nodejs git screen

</span><span class="hljs-comment"><span class="com">#Centos系统</span></span><span class="pln">
curl </span><span class="pun">-</span><span class="pln">sL https</span><span class="pun">:</span><span class="com">//rpm.nodesource.com/setup_10.x | bash -</span><span class="pln">
yum install nodejs git screen </span><span class="pun">-</span><span class="pln">y</span>

2、安装Forsaken Mail

<span class="hljs-attribute"><span class="pln">git</span></span><span class="pln"> clone https</span><span class="pun">:</span><span class="com">//github.com/denghongcai/forsaken-mail.git</span><span class="pln">
cd forsaken</span><span class="pun">-</span><span class="pln">mail
</span><span class="hljs-comment"><span class="com">#安装Forsaken Mail</span></span><span class="pln">
npm install
</span><span class="hljs-comment"><span class="com">#后台运行Forsaken Mail</span></span><span class="pln">
screen </span><span class="pun">-</span><span class="pln">S forsakenmail
npm start</span>

最后按Ctrl+A,再按D键返回主界面,然后打开http//mx.xx.com:3000就可以查看Forsaken Mail邮箱界面了,如果你打不开界面,可能还需要开启防火墙端口,一般该情况在CentOS系统上出现最多,这里就说下CentOS开启操作。

<span class="hljs-comment"><span class="com">#Centos 6系统</span></span>
<span class="hljs-attribute"><span class="pln">iptables</span></span> <span class="pun">-</span><span class="pln">I INPUT </span><span class="pun">-</span><span class="pln">p tcp </span><span class="pun">--</span><span class="pln">dport </span><span class="hljs-number"><span class="lit">3000</span></span> <span class="pun">-</span><span class="pln">j ACCEPT
service iptables save
service iptables restart

</span><span class="hljs-comment"><span class="com">#CentOS 7系统</span></span><span class="pln">
firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">zone</span><span class="pun">=</span><span class="kwd">public</span> <span class="pun">--</span><span class="pln">add</span><span class="pun">-</span><span class="pln">port</span><span class="pun">=</span><span class="hljs-number"><span class="lit">3000</span></span><span class="pun">/</span><span class="pln">tcp </span><span class="pun">--</span><span class="hljs-literal"><span class="pln">permanent</span></span><span class="pln"> 
firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">reload</span>

Docker安装

1、安装Docker

<span class="hljs-comment"><span class="com">#CentOS 6</span></span>
<span class="hljs-attribute"><span class="pln">rpm</span></span> <span class="pun">-</span><span class="pln">iUvh http</span><span class="pun">:</span><span class="com">//dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm</span><span class="pln">
yum update </span><span class="pun">-</span><span class="pln">y
yum </span><span class="pun">-</span><span class="pln">y install docker</span><span class="pun">-</span><span class="pln">io
service docker start
chkconfig docker </span><span class="hljs-literal"><span class="pln">on</span></span>

<span class="hljs-comment"><span class="com">#CentOS 7、Debian、Ubuntu</span></span><span class="pln">
curl </span><span class="pun">-</span><span class="pln">sSL https</span><span class="pun">:</span><span class="com">//get.docker.com/ | sh</span><span class="pln">
systemctl start docker
systemctl enable docker</span><span class="pun">.</span><span class="pln">service</span>

2、安装Forsaken Mail

<span class="pln">docker run </span><span class="hljs-comment"><span class="pun">--</span><span class="pln">name forsaken</span><span class="pun">-</span><span class="pln">mail </span><span class="pun">-</span><span class="pln">d </span><span class="pun">-</span><span class="pln">p </span><span class="lit">25</span><span class="pun">:</span><span class="lit">25</span> <span class="pun">-</span><span class="pln">p </span><span class="lit">3000</span><span class="pun">:</span><span class="lit">3000</span><span class="pln"> denghongcai</span><span class="pun">/</span><span class="pln">forsaken</span><span class="pun">-</span><span class="pln">mail</span></span>

安装成功后打开http//mx.xx.com:3000就可以了,如果打不开界面请参考NPM安装步骤。

配置Https访问

如果你不习惯使用http//mx.xx.com:3000,或者想使用Https域名访问主界面,那我们可以使用Caddy反代。

这里所使用的域名只能是上面设置MX记录的xx.com,并提前将域名A记录解析到服务器IP

1、安装Caddy
使用命令:

<span class="hljs-attribute"><span class="pln">wget</span></span> <span class="pun">-</span><span class="pln">N </span><span class="pun">--</span><span class="hljs-literal"><span class="kwd">no</span></span><span class="pun">-</span><span class="pln">check</span><span class="pun">-</span><span class="pln">certificate https</span><span class="pun">:</span><span class="com">//raw.githubusercontent.com/ToyoDAdoubi/doubi/master/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh install http.filemanager</span>
<span class="hljs-comment"><span class="com">#备用地址</span></span><span class="pln">
wget </span><span class="pun">-</span><span class="pln">N </span><span class="pun">--</span><span class="hljs-literal"><span class="kwd">no</span></span><span class="pun">-</span><span class="pln">check</span><span class="pun">-</span><span class="pln">certificate https</span><span class="pun">:</span><span class="com">//www.moerats.com/usr/shell/Caddy/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh install http.filemanager</span>

2、配置Caddy

<span class="hljs-comment"><span class="com">#以下全部内容是一个整体,请修改2个域名后一起复制到SSH运行!</span></span>
<span class="hljs-attribute"><span class="pln">echo</span></span> <span class="hljs-string"><span class="str">"xx.com {
 gzip
 tls admin</span><span class="hljs-variable"><span class="str">@moerats</span></span><span class="str">.com
 proxy / mx.xx.com:3000
}"</span></span> <span class="pun">></span> <span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">caddy</span><span class="pun">/</span><span class="typ">Caddyfile</span>

tls参数会自动帮你签发ssl证书,如果你要使用自己的ssl,改为tls /root/xx.crt /root/xx.key即可。后面为ssl证书路径。

3、启动Caddy

<span class="str">/etc/</span><span class="pln">init</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">caddy </span><span class="hljs-keyword"><span class="pln">start</span></span>

最后可以打开https://xx.com访问了。

发表评论