How to Install RainLoop Webmail on Ubuntu 16.04

In previous articles, we discussed how to set up your own mail server on Ubuntu from scratch. This tutorial is going to show you how to install RainLoop Webmail on Ubuntu 16.04 with Apache or Nginx web server. RainLoop is a simple, modern, fast and open-source Web-based email client written in PHP.

RainLoop webmail features:

  • A modern web interface.
  • Fast and lightweight
  • Supports both SMTP and IMAP.
  • Supports multiple accounts, which means you can access all your email addresses from one place.
  • Supports two-factor authentication.
  • Integration with Facebook, Twitter, Google and Dropbox.
  • Direct access to mail server, no database needed.
  • Easy to install and upgrade (one-click upgrade in the admin panel)

. There are two editions of RainLoop:

  • community edition released under the AGPL v3 license
  • standard edition released under the RainLoop software license.

We will use the free and open-source community edition in this tutorial.

Step 1: Install Apache, PHP7 or Nginx, PHP7

If you use Apache and PHP7, then install them on Ubuntu 16.04 with:

sudo apt update

sudo apt install apache2 php7.0 libapache2-mod-php7.0

If you use Nginx and PHP7, then install them with:

sudo apt update

sudo apt install nginx php7.0 php7.0-fpm

And install the following PHP extensions which are required by RainLoop.

sudo apt install php7.0-curl php7.0-xml

Step 2: Download and Install RainLoop Webmail on Ubuntu 16.04

First, make a directory for rainloop in the current working directory.

mkdir rainloop

Cd into the directory and download the latest RainLoop community edition with the following commands:

cd rainloop

curl -s http://repository.rainloop.net/installer.php | php

Once that’s done, move this directory to /var/www/.

cd ..

sudo mv rainloop /var/www/

Now set web server user (www-data) as the owner.

sudo chown www-data:www-data /var/www/rainloop/ -R

Step 3: Configure a Virtual Host for RainLoop

We can use either Apache or Nginx web server.

Apache

If you like to use Apache web server, then create the virtual host file with the following command:

sudo nano /etc/apache2/sites-available/rainloop.conf

Put the following text into the file. Replace red text with your actual info.

<VirtualHost *:80>
  ServerName mail.example.com
  DocumentRoot "/var/www/rainloop/"
  ServerAdmin admin@example.com

  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>

</VirtualHost>

Save and close the file. Then enable this virtual host.

sudo a2ensite rainloop.conf

And reload Apache.

sudo systemctl reload apache2

Installing TLS/SSL Certificate (Apache)

If you want to add HTTPS to webmail, then you can obtain a free TLS/SSL certificate from Let’s Encrypt CA. First Let’s install the certbot client. The following command will install the client and apache plugin from the official certbot PPA.

sudo apt install software-properties-common

sudo add-apt-repository ppa:certbot/certbot

sudo apt update

sudo apt install certbot python-certbot-apache

Now issue the following command to obtain a free TLS/SSL certificate. Replace the red-colored text with your actual email address and domain name.

sudo certbot --apache --agree-tos --email your-email-address -d mail.example.com

You will be asked to choose easy or secure. It’s recommended to choose secure so that all http requests will be redirected to https.

let's encrypt apache

Once you hit the OK button, a free TLS/SSL certificate is obtained and installed on the Apache virtual host.

Nginx

If you like to use Nginx web server, then create the virtual host file with the following command:

sudo nano /etc/nginx/conf.d/rainloop.conf

Put the following text into the file. Replace mail.example.com with your own domain name.

server {
   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.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
   }
 
   location ^~ /data {
       deny all;
   }
}

Save and close the file. Then test Nginx configurations.

sudo nginx -t

If the test is successful, reload Nginx configurations.

sudo systemctl reload nginx

Installing TLS/SSL Certificate (Nginx)

Let’s obtain a free TLS certificate from Let’s Encrypt. The following command will install the certbot client and Nginx plugin from the official certbot PPA.

sudo apt install software-properties-common

sudo add-apt-repository ppa:certbot/certbot

sudo apt update

sudo apt install certbot python-certbot-nginx

Then use the Nginx plugin to obtain and install the certificate by running the following command. Replace red text with your actual email address and domain name.

sudo certbot --nginx --agree-tos --redirect --staple-ocsp --email your-email-address -d mail.example.com

You will see the following text indicating that you have successfully obtained a TLS certificate. Your certificate and chain have been saved at /etc/letsencrypt/live/mail.example.com/ directory.

squirrelmail let's encrypt

The Nginx plugin automatically install TLS certificate for you. Now if you visit http://mail.example.com, you will be redirected to https://mail.example.com.

Step 4: Configure RainLoop Webmail

Log into RainLoop admin panel via the following URL.

mail.example.com/?admin

Default username is admin and default password is 12345.

rainloop webmail admin login page

Once you are logged in, it’s recommended to change both your username and password since admin is an easy target. Click the security tab on the left pane. Update your password first, then re-login and update your username.

rainloop webmail ubuntu 16.04

To access your emails through RainLoop, you need to configure email server settings in the Domains tab. By default, 4 email domains are added: gmail.com, outlook.com, qq.com, yahoo.com.

rainloop webmail multiple email domains

The SMTP server settings and IMAP server settings for these email domains are configured by RainLoop, but only Gmail is enabled by default. To enable other 3 email domains, simple put a check inside the box to the right.

To be able to access your own email server, click the Add Domain button and enter the IMAP and SMTP server settings of your own email server.

  • IMAP: server mail.example.com, port 143, Secure STARTTLS.
  • SMTP: server mail.example.com, port 587, Secure STARTTLS. Tick on Use Authentication.

rainloop imap and smtp settings

If Rainloop and Postfix/Dovecot are running on the same server, then you can use the following configurations, so your server doesn’t have to look up the domain in DNS and establish TLS connection.

  • IMAP: server 127.0.0.1, port 143, Secure None.
  • SMTP: server 127.0.0.1, port 25, Secure None. Don’t use authentication on port 25.

rainloop postfix dovecot on the same server

You also need to enable your own email domain by putting a check inside the box on the right, or the error domain is not allowed will appear when logging into your email address.

After finishing the configuration, enter your RainLoop webmail domain name in browser address bar without /?admin suffix.

mail.example.com

And log into your email account.

rainloop ubuntu

RainLoop webmail

rainloop webmail ubuntu

If authentication failed, then you may need to enable short login in the IMAP server settings page.

That’s all you need to do in order to access your emails on Gmail, outlook mail or your own email domain. If you add multiple email accounts, you can easily switch between them from the user drop-down menu. Very cool indeed! You can also configure other settings and customize your webmail interface.

Removing Sensitive Information from Email Headers

By default, Rainloop will add a X-Mailer email header, indicating that you are using Rainloop webmail and the version number. You can tell Postfix to ignore it so recipient can not see it. Run the following command to create a header check file.

sudo nano /etc/postfix/smtp_header_checks

Put the following lines into the file.

/^X-Mailer.*RainLoop/           IGNORE

Save and close the file. Then edit the Postfix main configuration file.

sudo nano /etc/postfix/main.cf

Add the following line at the end of the file.

smtp_header_checks = regexp:/etc/postfix/smtp_header_checks

Save and close the file. Then run the following command to rebuild hash table.

sudo postmap /etc/postfix/smtp_header_checks

Reload Postfix for the change to take effect.

sudo systemctl reload postfix

Now Postfix won’t include X-Mailer: Rainloop in email headers.

Wrapping Up

I hope this tutorial helped you install RainLoop Webmail on Ubuntu 16.04. As always, if you found this post useful, then subscribe to our free newsletter.

Rate this tutorial
[Total: 16 Average: 4.3]

5 Responses to “How to Install RainLoop Webmail on Ubuntu 16.04

  • dailytut
    4 years ago

    Thanks for the detailed tutorial. i was searching for webmail setup with my new ubuntu installation. Thank you very much (Y).

    Robin.

  • Hello,
    Thanks a million for this wonderful turorial.
    I have a very humble request. Could you kindly explain to us the roles all these products play in the emailing process.
    For example what does Postfix do? and what does it do with Dovecot. I know Rainloop is an email client, and IredMail is a mailing server, but I haven’t been successful in understanding what a mailing server does. Is Gmail an email server or client? I’m really confused, please help.

    • Postfix is a state-of-the-art message transport agent (MTA), aka SMTP server, which serves two purposes.

      1.) It’s responsible for transporting email messages from a mail client/mail user agent (MUA) to a remote SMTP server (When you need to send emails in your mail client).
      2.) It’s also used to accept emails from other SMTP servers (when a person sends email from his/her Gmail account to your email address).

      Dovecot is an IMAP and POP3 server. Dovecot allows the mail client to fetch emails from mail server, so you can read emails in your mail client.

      iRedMail is a script that automatically sets up an email server for you, so you don’t have to do the dirty work. iRedMail itself is not a mailing server. It can help you install a mailing list manager (mlmmj) for you. A mailing list manager allows you to send emails to unlimited number of recipients.

      The Gmail web interface is a web-based email client. Gmail has its own SMTP server, IMAP server and POP3 server.

  • Thank you for your help. You really saved me time. On all fronts, including adding a domain with the shortcuts if the server is on the same machine. Really, thank you for your help, it saved me so much time and hopefully I help people when I have a chance.

  • limace255
    4 weeks ago

    Hello there,

    Just a missing info, on Apache configuration, those lines may be important, to get rid of warning about “data” folder permissions :

      
        Options -Indexes
        Deny from all
      
    

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.


The maximum upload file size: 2 MB.
You can upload: image.