How to set up a Mail Server that uses GMail as the backend, on Ubuntu/Apache with Multiple Domains on Virtual Hosts

I have multiple domains set up on multiple virtual hosts (Ubuntu 14 with Apache).

I want to create a simple email send and receive system that uses GMail accounts as POP3 mailboxes.

I don’t need WebMail, or Spam filtering or Virus filtering, etc., because GMail will do that. I don’t need IMAP.

Each domain needs a single email address, no more.

What’s is a simple recipe to achieve this? (Note that I have virtual hosts, and I would like each domain to get its own email address using that domain).

Step by step instructions will be most helpful!

keywords: postfix dovecot iredmail qmail mx record cname


Well the commands are same just the starting “phrases” are replaced by sudo apt-get :)

If you compare the commands of CentOS with that of Debian (Ubuntu), you will understand easily!

@saurabh Thank you. I won’t be able to use that article though because I have Ubuntu 14 and that article is for CentOS.

@gentlecalm As stated earlier, you may follow the guide in the article and skip the part to configure webmail. However, even if you install webmail, still you can use Gmail to import mails and send them from your domain mail id.

Here is another guide I found just for your use case.

@saurabh Thank you so much for your suggestions. I actually do, in a way, want to use WebMail. Except that I want GMail to be the WebMail client in this case, instead of SquirrelMail or some such. So I was planning to use Dovecot POP3 to retrieve email into GMail, and use Postfix’s SMTP server to send from GMail. Should I nevertheless install WebMail? (Also, I may have got some concepts mixed up.)

Just a suggestion, do not ignore Spam Filtering and Virus Filerting because once you install postfix to send mails, the server readily becomes vulnerable to spam attacks!

All you need to do is install Postfix MTA which can send mails and then change it’s config file to use GMail ports and authentication. Also when you install Dovecot MDA, you can again set your POP settings to retrieve mails from GMail.

But the question is, why would someone want to duplicate the content of GMail on his server when he is not going to use Webmail?

Don’t forget to open ports to send and receive mails on your server! For example, Port 25 is the default port for SMTP!

Here is an article which might come in handy for your to start on your server. You can skip the installationnof SquirrelMail in this article!

– Regards Saurabh Managed Cloud Hosting For PHP Applications On DigitalOcean IaaS

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

We have this setup working well with Ubuntu 16.04, with multiple domains / Gmail boxes, spam/antivirus filtering, dmarc setting (for our domains) and dmarc checking/blocking (for other domains). Also when an email is returned by Gmail as being unsuitable it isn’t sent again (even though Gmail may have given a transient error code) and the sender’s ip is banned for a period.