很多时候,我们想使用互联网某些服务的时候,都会要求邮箱注册,而我们都知道,越多地方知道我们的邮箱地址,就越容易收到垃圾邮件,这个时候,我们就可以利用一次邮件系统来帮助我们。
forsaken-mail项目是一个开源的项目,基于nodejs完成的项目,项目地址为:forsaken-mail。
为了能使用此项目,我们需要一台VPS,一个域名。
首先,为服务器安装nodejs和npm支持
wget https://nodejs.org/dist/v8.9.4/node-v8.9.4-linux-x64.tar.xz && tar -xvf node-v8.9.4-linux-x64.tar.xz -C /usr/local && ln -s /usr/local/node-v8.9.4-linux-x64/bin/* /usr/local/bin
在服务器上clone此项目:
git clone https://github.com/denghongcai/forsaken-mail.git
安装pm2
npm install pm2
使用pm2启动forsaken-mail
cd forsaken-mail pm2 start /bin/www pm2 startup pm2 save
至此,forsaken-mail已经启动成功,可以通过ip:3000来访问。
利用nginx或apache2转发绑定域名
这里只介绍apache2方式。
安装apache2并添加模块
apt-get install apache2 a2enmod proxy a2enmod proxy_http
添加配置文件:
echo ' <VirtualHost *:80> ServerName oncemail.gongyuhua.cn ProxyRequests off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /> ProxyPass http://localhost:3000/ ProxyPassReverse http://localhost:3000/ </Location> </VirtualHost> ' > /etc/apache2/sites-available/mail.conf a2ensite mail.conf systemctl restart apache2
至此,你可以通过oncemail.gongyuhua.cn访问邮件系统。
不过,为了能正常收到邮件,还必须将oncemail.gongyuhua.cn的MX记录解析到服务器ip。
最终效果:
Forsaken-mail
好文章!666,学习了