Total Pageviews

Friday 9 June 2017

Mailsac

 A disposable SMTP test server and email web client frontend, build on Node.js, Mongo and Redis https://mailsac.com

The receive-only mail server powering Mailsac.com.

You can throw it onto a server pretty easily and use it for testing incoming email.

Mailsac >=2.0.0 is a complete rewrite and not compatible with <2.0.0.
Setup
Instructions for Ubuntu 14.04

On a fresh server, download the script ./install/ubuntu-1404.sh and run it:

wget https://raw.githubusercontent.com/ruffrey/mailsac/master/install/ubuntu-1404.sh
sudo sh ubuntu-1404.sh

Or from a local version of the repository:

ssh root@MYHOSTNAME 'bash -s' < install/ubuntu-1404.sh

Instructions for everything else

Remove or disable any services that are bound to ports 25 and 587. These are used by SMTP and required by the Mailsac ./smtp-server.js.
Redeploy

There is a helper script ./deploy which can be used to deploy the current directory to a remote server where Mailsac has been installed.

./deploy root@mailsac.com # assumes your ssh key is on host

Deps

    Node.js >= 0.12.0
    MongoDB
    Redis
    Nothing blocking the mail ports (25 and 587)

Running

node app

There are DEBUG= environment variables which will help with troubleshooting. See ./package.json - "scripts".
Advanced configuration

Change ./config/default.json or add config files matching NODE_ENV environment variable. See more instructions for node-config: https://github.com/lorenwest/node-config/wiki
Not for Node.js cloud hosts

Mailsac runs on VPS or bare servers.

It will not work on Node.js cloud services (like AppFog, Heroku) because they won't give you access to SMTP ports.

You could use a service like Docker to manage and deploy Node.js apps on a VPS. Or just deploy to a normal VPS using the ./deploy script, git, or something else.
Plugins

Pluggable features can be added to Mailsac.

There are hooks into the UI application and SMTP processes.

An example plugin is found in the ./plugins/ folder. See it for details.

A plugin must either be:

    a file with .plugin.js as the extension

You can extend the base ./views/layout.jade template by having the following jade files in your plugin folder.

    ./plugins/myexample.plugin/includes/head.jade
    ./plugins/myexample.plugin/includes/footer.jade

Development

Follow the code quality guidelines by running:

npm run lint



from  https://github.com/ruffrey/mailsac

----------------



Mailsac临时邮件使用以及自己搭建邮箱教程

Mailsac是一个用于接收和发送邮件的平台。非常方便的创建邮箱,然后收发邮件!

PS:发送邮件需要注册账号。

这个有点类似我们曾经提到的 forsaken-mail  。

但是Mailsac是会将邮件存储起来,下次再次访问该邮箱前缀的时候能看见历史邮件。

值得关注的是 Mailsac 的核心代码开源了,我们可以自己搭建属于自己专属的收件系统。
官网地址

https://mailsac.com


开源项目

https://github.com/ruffrey/mailsac




简单操作
提醒一下,在Mailsac接收的重要邮件,用完后一定要删除。因为这个邮箱可能被别人看到或使用。
接收邮件

无需注册账号,直接访问 https://mailsac.com 填写一个你钟意的邮箱前缀即可创建邮件,然后可以接收邮件了。
发送邮件

首先需要注册一个账号。

注册地址:https://mailsac.com/register

然后直接回复邮件即可。

注意:发送邮件可能有收不到的情况。


自定义域名

Mailsac比较不错的一点就是可以使用自己的域名!

简单几步即可实现。

1)将你的域名的MX记录解析到 mailsac~~

注意需要解析hostname必须是 @

如果你想将二级或者三级域名来做 @的解析。请参考 "二级域名如何实现NS的独立解析".



2)我们直接到https://mailsac.com 修改邮箱后缀即可!!!

然后快看看是不是能收到邮件啦!


Ubuntu下,部署源码

目前开源项目只支持邮件接收。不能发送邮件。

但是可定制性很强!


部署代码

1)对于ubuntu系统官方提供了一键部署,要求是一个空白的ubuntu系统直接执行以下代码即可:

wget https://raw.githubusercontent.com/ruffrey/mailsac/master/install/ubuntu-1404.sh
sudo sh ubuntu-1404.sh



2)执行代码后如上图,然后访问 http://ip:3000 如下图。

目前还是无法使用的,我们需要绑定域名才行!


绑定域名

1)首先需要将域名的A记录解析到你vps的IP上。

2)然后将MX记录解析到域名上。

3)最后我们就可以使用域名访问了。创建一个临时邮箱,顺利接收到文件


绑定更多域名

只需要将域名的MX记录解析到指定域名上即可。

解析成功后,修改邮箱后缀即可接收邮件了。


修改配置

比如我们需要修改自己的logo,名称等信息。需要直接修改源码。

在 view/ 目录里面,是 jade 格式。相信大佬们经过简单研究轻松搞定!

配置文件的位置:config/default.json 可以修改端口,收件相关配置信息。

可参考官方提供的文献: https://github.com/lorenwest/node-config/wiki/Configuration-Files

本次演示安装目录在 /opt/mailsac/



修改完配置需要重新启动一下:sudo service mailsac restart


CentOS下,部署源码

Mailsac开源项目并没有提供CentOS系统下的安装脚本。

这里就演示一下如何在CentOS6 系统中部署。

这部分脚本比较多,可以自己合成一键脚本。


环境要求

Node.js >= 0.12.0

MongoDB

Redis

Nothing blocking the mail ports (25 and 587)


Node.js的安装,不再赘述。

MongoDB的安装:
这里只贴出全部代码,依次执行即可。
本部分内容参考自 https://my.oschina.net/chinaearl/blog/111077
#下载
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.4.4.tgz
tar zxvf mongodb-linux-x86_64-amazon-3.4.4.tgz
mv mongodb-linux-x86_64-amazon-3.4.4 /usr/local/mongodb
cd /usr/local/mongodb
mkdir -p ./data/db/
mkdir logs

#启动
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/logs/mongodb.log --fork

#开机启动
echo "/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/logs/mongodb.log --fork" >> /etc/rc.local
   
#下载
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.4.4.tgz
tar zxvf mongodb-linux-x86_64-amazon-3.4.4.tgz
mv mongodb-linux-x86_64-amazon-3.4.4 /usr/local/mongodb
cd /usr/local/mongodb
mkdir -p ./data/db/
mkdir logs

#启动
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/logs/mongodb.log --fork

#开机启动
echo "/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/logs/mongodb.log --fork" >> /etc/rc.local




Redis的安装:
这里只贴出全部代码,依次执行即可。
本部分内容参考自:  https://segmentfault.com/a/1190000002685224
wget http://download.redis.io/releases/redis-2.8.13.tar.gz
tar -xzvf redis-2.8.13.tar.gz
mv redis-2.8.13 /usr/local/redis
cd /usr/local/redis
make&&make install
mkdir -p /etc/redis
cp redis.conf /etc/redis

#修改配置: daemonize yes (no-->yes)
vi /etc/redis/redis.conf

#启动
/usr/local/bin/redis-server /etc/redis/redis.conf

#检查是否启动成功
ps -ef | grep redis

#开机启动
echo "/usr/local/bin/redis-server /etc/redis/redis.conf &" >> /etc/rc.local
wget http://download.redis.io/releases/redis-2.8.13.tar.gz
tar -xzvf redis-2.8.13.tar.gz
mv redis-2.8.13 /usr/local/redis
cd /usr/local/redis
make&&make install
mkdir -p /etc/redis
cp redis.conf /etc/redis

#修改配置: daemonize yes (no-->yes)
vi /etc/redis/redis.conf

#启动
/usr/local/bin/redis-server /etc/redis/redis.conf

#检查是否启动成功
ps -ef | grep redis

#开机启动
echo "/usr/local/bin/redis-server /etc/redis/redis.conf &" >> /etc/rc.local


释放邮箱端口

这里需要将占用25 和 587 端口的程序结束掉。
killall sendmail
/etc/init.d/postfix stop
chkconfig --level 2345 postfix off
chkconfig --level 2345 sendmail off

  
部署项目

首先克隆一份开源项目源码
git clone https://github.com/ruffrey/mailsac.git
cd mailsac

#安装PM2工具
npm install -g pm2

#安装项目需要的库
npm install

#启动
pm2 start app.js

#设置开机启动
pm2 startup
pm2 save
git clone https://github.com/ruffrey/mailsac.git
cd mailsac

#安装PM2工具
npm install -g pm2

#安装项目需要的库
npm install

#启动
pm2 start app.js

#设置开机启动
pm2 startup
pm2 save



运行成功后即可访问了http://ip:3000
绑定域名等操作请参考文中: Ubuntu源码部署 里面的内容,不再重复说明。

最后说明

使用过程中一定要注意,重要邮件一定要删除。
mailsac提供将邮箱私有化和API调用,但是都是需要付费的。

No comments:

Post a Comment