[IRedMail] 如何建立自己的MailServer和WebClient端
create dropets
- 3 GB Memory / 20 GB Disk / SGP1 - Ubuntu 16.04.3 x64
- hostname: mail.yourdomain.com
- with your ssh key
login with root by ssh key
$ ssh root@[your.ip]
update all
$ apt update; apt -y upgrade;
check hostname
$ nano /etc/hostname
# mail
$ hostname
# mail
$ hostname -f
# mail.yourdomain.com
setup hosts
make sure your domain is before localhost
$ nano /etc/hosts
# 127.0.0.1 mail.yourdomain.com mail localhost localhost.localdomain
do not move other lines ex. “127.0.1.1 mail.yourdomain.com mail”
then we need to reboot once.
$ reboot
download iredmail and unzip it
$ sudo apt-get install bzip2
$ wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.7.tar.bz2
$ tar xjf iRedMail-0.9.7.tar.bz2
$ cd iRedMail-0.9.7
setup iredmail
$ bash iRedMail.sh
# 1. <yes>
# 2. where store? [/var/vmail] <Next>
# 3. Which Http Serv.?[(*) Nginx] <Next>
# 4. Which DB? [(*) MySQL] <Next>
# 5. MySQL root password? [123456] <Next>
# 6. default mail domain? [yourdomain.com] <Next>
# 7. mail domain admin password? [123456] <Next>
# 8. option component? [select all] <Next>
# < Question > Continue? [y|N] y
# ...
# ...(long long waiting)
# ...(we can go to next step while waiting)
# ...
# < Question > Would you like to use firewall rules provided by iRedMail?
# < Question > File: /etc/default/iptables, with SSHD port: 22. [Y|n] n
we use ufw firewall setting for last step
after all we need to reboot
$ reboot
Setup DNS
@ 300 IN A 100.100.100.1
@ 300 IN MX 10 mail.yourdomain.com.
@ 300 IN MX 20 mail.yourdomain.com.
@ 300 IN TXT "v=spf1 ip4:100.100.100.1 -all"
mail 300 IN A 100.100.100.1
DNS TEST
https://mxtoolbox.com
check our apps
- Web admin panel (iRedAdmin): httpS://mail.mealbox.com.tw/iredadmin/
- Roundcube webmail: httpS://mail.mealbox.com.tw/mail/
- SOGo groupware: httpS://mail.mealbox.com.tw/SOGo/
* Username: postmaster@mealbox.com.tw
* Password: 1234
mail sp test
https://www.mail-tester.com/
setup servername
$ sudo nano /etc/nginx/sites-conf.d/default/0-server_name.conf
server_name _;
to
server_name mail.yourdomain.com;
$ sudo nginx -t $ sudo service nginx restart
install certbot
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-nginx
$ sudo certbot --nginx certonly
# Enter email address ? your@gmail.com
# Which names would you like to activate HTTPS for?
# -------------------------------------------------------------------------------
# 1: mail.yourdomain.com
# -------------------------------------------------------------------------------
# select 1
$ mv /etc/ssl/private/iRedMail.key /etc/ssl/private/iRedMail.key.bak
$ mv /etc/ssl/certs/iRedMail.crt /etc/ssl/certs/iRedMail.crt.bak
$ ln -s /etc/letsencrypt/live/mail.mealbox.com.tw/privkey.pem /etc/ssl/private/iRedMail.key
$ ln -s /etc/letsencrypt/live/mail.mealbox.com.tw/fullchain.pem /etc/ssl/certs/iRedMail.crt
autorenew checkout
$ sudo certbot renew --dry-run
setup ufw firewall
$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing
$ sudo ufw allow ssh
$ sudo ufw allow http
$ sudo ufw allow https
$ sudo ufw allow smtp
$ sudo ufw allow submission
$ sudo ufw allow pop3
$ sudo ufw allow pop3s
$ sudo ufw allow imap
$ sudo ufw allow imaps
留言