How to Setup a Free Mail Server with RoundCube on OpenShift - Archived

OpenShift Email Server Picture
Some time ago I published an article on Using Mailgun For Email in the Cloud for sending and receiving e-mail to and from OpenShift’s public platform as a service (Paas). Afterwards several people asked if it would be possible to set up a private e-mail solution on OpenShift using RoundCube. It is possible and it’s not difficult as you’ll learn in this follow up. So, let’s get our hands dirty!

   

The Solution is RoundCube

There isn’t anything fancy about this solution. Mailgun provides SMTP and IMAP servers that can be accessed from external services. RoundCube is open-source PHP based web-mail client with IMAP and SMTP support. The is no hard-coded dependency and it’s very simple to change the provider of the e-mail servers.

RoundCube on OpenShift --SMTP--> external MailGun service --IMAP--> RoundCube on OpenShift

Setting up RoundCube on OpenShift

For hosting the RoundCube application we need PHP gear and MySQL server as a backend.

rhc app create roundcube php-5
rhc cartridge add mysql -a roundcube

Move the the repository that was cloned on your local machine and pull RoundCube sources pre-configured for OpenShift.

cd roundcube
git pull -s recursive -X theirs git://github.com/openshift-quickstart/roundcube-openshift-quickstart.git

Now your repository contains RoundCube with default configuration to use MySQL as a backend on OpenShift and Mailgun as a SMTP/IMAP provider.

Now we need to populate the MySQL database. The simplest way is to use PHPMyAdmin to handle the database. However, you could also use port-forwarding or command-line tools inside the OpenShift gear to populate your database from your local machine!

Now I will use the PHPMyAdmin application, that is provided as a cartridge by OpenShift

rhc cartridge add phpmyadmin -a roundcube

After running this command, the output will contain the connection information for you, so log in and use the tool to import the database file that is located in your repository under the “php/SQL/mysql.initial.sql” directory.

Now, let’s push the application to the platform:

git push

After OpenShift is configured, navigate to you application URL to see RoundCube.

How To Setup Mailgun

See the previous article on Configuring Mailgun on OpenShift if you need more information about Mailgun and about signing up for the service. I will assume here, you already have an account.

On the Domains tab click on the link with the name of your domain. On the next page you will see on the right side SMTP Authentication. You can use these credentials to login into the RoundCube web mail application.

From here, you can start using the service with the e-mail address “postmaster@<your domain>”. If you want to create a different user instead of postmaster, you can do that on the Mailboxes tab.

Conclusion

Setting up an e-mail system is simple using all the free services on the Internet. In this tutorial we used OpenShift as a hosting provider to host an open-source web-mail client called RoundCube. As an e-mail provider Mailgun was used to send and receive e-mails.

What’s Next?

Categories
News
Tags
, ,
Comments are closed.