前言

RainLoop 是一个简单,现代,快速和开源的基于 Web 的电子邮件客户端,用 PHP 编写。

Rainloop 特性

  • 现代的 Web 界面,允许上传自定义主题
  • 快速轻便
  • 同时支持 SMTP 和 IMAP
  • 支持多个帐户,可以从一个地方访问所有电子邮件地址。
  • 支持双因素身份验证。
  • 与 Facebook, Twitter, Google, and Dropbox 集成
  • 无需数据库, 可以直接访问邮件服务器
  • 易于安装和升级(在管理面板中一键升级)

Rainloop 版本选择

Rainloop 有标准版和社区版两个版本, 本文使用社区版(免费)

安装

Step 1: Install Apache + PHP7 或者 Nginx + PHP7

如果使用 Apache 和 PHP7

1
2
sudo apt update
sudo apt install apache2 php7.4 libapache2-mod-php7.4

如果使用 Nginx 和 PHP7

1
2
sudo apt update
sudo apt install nginx php7.4 php7.4-fpm php7.4-curl php7.4-xml

Step2: 下载 Rainloop

1
2
3
4
wget https://www.rainloop.net/repository/webmail/rainloop-latest.zip
mkdir /var/www/rainloop
unzip rainloop-latest.zip -d /var/www/rainloop
sudo chown www-data:www-data /var/www/rainloop/ -R

Step 3: 配置 vHost

使用 Apache

mail.example.com 换成你自己的域名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
sudo tee /etc/apache2/sites-available/rainloop.conf <<-'EOF'
<VirtualHost *:80>
ServerName mail.example.com
DocumentRoot "/var/www/rainloop/"

ErrorLog "/var/log/apache2/rainloop_error_log"
TransferLog "/var/log/apache2/rainloop_access_log"

<Directory />
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>

<Directory /var/www/rainloop/data>
Require all denied
</Directory>

</VirtualHost>
EOF
sudo a2dissite 000-default
sudo a2ensite rainloop.conf
sudo systemctl reload apache2

使用 Nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
sudo tee /etc/nginx/conf.d/rainloop.conf <<-'EOF'
server {
listen 80;
listen [::]:80;
server_name mail.example.com;

root /var/www/rainloop;
index index.php index.html;

access_log /var/log/nginx/rainloop_access.log;
error_log /var/log/nginx/rainloop_error.log;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ ^/(.+\.php)$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}

location ^~ /data {
deny all;
}
}
EOF

sudo nginx -t
sudo nginx -s reload

Step 4: 配置 TLS/SSL 证书

Apache

1
2
apt -y install python3-certbot-apache
certbot --apache --agree-tos --no-eff-email --email xxxxx@example.com

Nginx

1
2
sudo apt install python3-certbot-nginx
certbot --nginx --agree-tos --no-eff-email --email xxxxx@example.co

如果你只打算用 cerbot

1
2
apt -y install certbot
certbot certonly --standalone --agree-tos --no-eff-email --email xxxxx@example.com -d mail.example.com

证书路径

1
2
/etc/letsencrypt/live/mail.example.com/fullchain.pem
/etc/letsencrypt/livemail.example.com/privkey.pem

Step 5: 配置 RainLoop Webmail

登录 https://mail.example.com/?admin, 默认用户名密码:admin/12345

相关参考