2

looking to install a mail server on a ubuntu server. I already have a web server running on it (apache/php/wordpress) But I am looking to also have a mail server. As I understand it I need to add MX records set up postfix for SMTP and dovecot for POP3 and IMAP.

My main question is, is it possible to install an email server on top of that?

Do I have to run the mail server with a second instance of apache or nginx?

Any tips for accomplishing this if at all possible?

Thank you

  • Yes, you can install a mail server on this system. No, mail servers are not related to web servers in anyway, so you won't need a(nother) web server to run a mail server. – David Foerster Feb 04 '18 at 21:57

1 Answers1

4

Yes, you can run a web server and a mail server on the same Ubuntu machine. That's a pretty common setup.

You will need:

  • host OS (Ubuntu is fine) with a static public IP address
  • firewall on your host OS (eg. combination of iptables with UFW on top)
  • registered domain and access to DNS server to change/add DNS records (for MX records as you mentioned)
  • webserver (apache is fine), programming language (PHP in your case), database (I assume MySQL or maybe MariaDB) for running your WordPress website(s)
  • mail transfer agent (postfix is fine), mail delivery agent (dovecot is fine) for running your mail server.

Additionally you might want to have:

  • full-text search (eg. using Solr) and spam filter (eg. using Rspamd) for your mail server
  • SSL certificate(s) for encryptet access to your website(s) and your mail accounts (eg. using Let's Encrypt / certbot-auto).
  • automatic security updates (eg. install unattended-upgrades)

Mail server setup:

Setting up a mail server correctly is a pretty complex task. There's a lot you need to know (like DKIM, DMARC, and SPF) so other mail servers will trust you and your e-mails won't end in your receivers' spam filter.

Luckily there is this excellent guide from Cullum Smith: How To Run Your Own Mail Server


Clarification:

You only need one instance of a web server software, for example Apache, to server multiple websites. But there are configurations possible where you would in fact use two instances of web server software, like Apache AND nginx on the same machine. But that has nothing to do with running a mail server. People install this combination of Apache & nginx for performance and security reasons – like nginx handling the external communication, talking to the internet real fast and secure (called a reverse proxy) and apache handling the internal communication, to PHP, MySQL and your website's files.

Your mail server won't have contact to your Apache instance (unless you plan to implement webmail access).

Bob
  • 401