Geek Culture
Published in

Geek Culture

How to Host a Personal Email Server on Google Cloud (for Free!): Part V

Hosting Webmail with Roundcube

Articles in this series

  1. Introduction & GCP Setup
  2. Configuring Postfix, Mailgun, & DNS Records
  3. Configuring Dovecot & Encryption
  4. Managing Virtual Mailboxes with MariaDB & Postfixadmin
  5. Hosting Webmail with Roundcube
  6. Filtering Spam with Rspamd & Sieve

If you have not read the previous articles in this series, please follow the links above to catch up. We now have our server running on GCP configured to send and receive email via the SMTP protocol and allow IMAP connections, while encrypting traffic with TLS. Our DNS records are configured properly to ensure email is delivered to & from us, and we are using virtual mailboxes so that there is no need for a local unix user for each mailbox. These are stored in a MariaDB database and managed using Postfixadmin via a web browser.

We have successfully connected from an email client, but what if we don’t have access to a personal device and need to access our mailbox? It sure would be handy to have a webmail client that we can access in our browser. Roundcube offers just that! It is a free, full-featured, open source webmail client written in PHP. On top of that, thanks to all the work we have already put in, it is going to be a piece of cake to add to our private email solution! Let’s get started.

Installing Rouncube

First, download Roundcube using wget. At the time of writing, the latest release of Roundcube is 1.5.2. You can always replace this build number with the latest release.


Extract the archive and move the content into the site’s root directory.

tar -xf roundcubemail-1.5.2-complete.tar.gz
sudo mv roundcubemail-1.5.2/* /var/www/mail/

Then, ensure that root owns the files. The exception being that www-data needs ownership of the temp/ and logs/ directories.

sudo chown -R root:root /var/www/mail/
sudo chown -R www-data:www-data /var/www/mail/temp/ /var/www/mail/logs/

We can now remove the default index file provided by Nginx.

sudo rm /var/www/mail/index.nginx-debian.html

Creating a Database and User for Roundcube

Roundcube needs a database to store user information separately from the virtual mailbox database we set up previously. We also need to create a user with proper permissions for Roundcube to access the database. Run mysql.

sudo mysql

Then, run the following commands to create the database and user with permissions. Replace password with a password of your choosing.

CREATE USER roundcube@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON roundcube.* TO roundcube@localhost;
flush privileges;

Afterwards, import the initial tables provided by Roundcube into the database.

sudo mysql roundcube < /var/www/mail/SQL/mysql.initial.sql

Finishing Installation in the Browser

Now navigate to to complete installation, replacing with your mail subdomain. If you’ve followed along with all of this series, you will see that we are missing three PHP extensions that Roundcube requires.

We can install them with the following command:

sudo apt install php-xml php-intl -y

After refreshing the page, we can now scroll down to the bottom and select NEXT to continue installation. For the most part, the default selections are fine, but if you want to customize your install further, you can learn more about the parameters here. We will have to edit a few sections though, starting with Database setup. Fill in with the details used to setup our database.

Next, we need to tell Roundcube to use secure IMAP & SMTP connections when communicating with Dovecot & Postfix. Enter the following in the IMAP Settings section, using your mail subdomain.

Then, configure the SMTP settings as follows.

We must use our subdomain here, but there is no reason to waste precious resources querying public DNS to find our own server! Let’s add a local DNS entry for our subdomain alongside localhost. Update the first line in /etc/hosts.       localhost

There are all kinds of great plugins to add functionality to Roundcube. Scroll down and check out the Plugins section to enable some before wrapping up.

NOTE: Some plugins may require additional steps to get up and running properly. A simple Google search for the plugin will easily find information on how to do so.

When you’re done, select CREATE CONFIG to create the configuration. As noted on the next page, we need to copy the configuration and save to /var/www/mail/config/

Afterwards, click CONTINUE. Now we can test that our SMTP and IMAP configurations are correct.

If either test fails, you can go back and edit the configuration using the link at the top of the page. Once successful, be sure to remove the installer directory from our site’s root directory as it is a security risk.

sudo rm -R /var/www/mail/installer/

Now navigate to your subdomain in the browser (i.e. and login.

Roundcube Webmail Interface


We can now access our mailbox from any device with a web browser! Let’s review how we accomplished this.

  • We downloaded Roundcube into our mail site’s root directory & set proper ownership on all files.
  • We created a database & user with correct permissions for Roundcube.
  • We followed the instructions provided by the Roundcube installer in our web browser, then removed the installer.
  • We also created a local DNS entry for our subdomain to prevent Roundcube from querying public DNS when communicating with Postfix & Dovecot.

Only one article left! Technically, if you feel that you are lucky enough to keep your email address out of the hands of evil-doers, then you could quit here. I warn you though, that is not the world we live in. Spam will eventually find your email server, tucked away in the cloud, and when it does, we will be ready for it. In the final article of this series, we will install Rspamd & Sieve in order to detect spam and reject it or send it to the Junk folder.

Thank you for reading! If you have found this series or article helpful, please clap and follow to be updated when the final piece is published.




A new tech publication by Start it up (

Recommended from Medium

WordPress Troubleshooting — Guide to basic WordPress problems and their solutions

CS373 Fall 2021: Entry #11

Why and how big MNC’s uses Amazon AWS?

Git — Maintaining multiple accounts

Visualise, focus and deliver work with a Kanban Board

Class and instance attributes

Blender 2.83 on Oracle Cloud Infrastructure — Part 3

Web Scraping using python and Beautifulsoup part 2

webscrapping using python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lee Phillips

Lee Phillips

Software developer. Flutter fanatic. Other interests include photography, sports, coffee, and food.

More from Medium

How to Host a Personal Email Server on Google Cloud (for Free!): Part I

WordPress attacks & Cloud Armor protection on GCP— True story.

Lets begin with Security — Cloud IAM in GCP

How to Import Data into Google Firestore