How to setup a mail server on Ubuntu to send and receive mail?

How to setup VPS server to send and receive emails without using 3rd party services (e.g. gmail, hotmail…).

I have a website hosted on my VPS that is using LAMP (Ubuntu 14.04 and PHP 7.1) I installed Postfix and was successfully able to send emails using PHP, however what I want is to be able to read and reply to emails that users send to my website email (e.g. so I googled on how to do this and most of the answers I was able to find was used some external SMTP like gmail.

My DNS Records look something like this with the exception of using the proper server IP and proper domain name:

|Type |	Name                | Value                                    | TTL        |
|A    |	@                   |                                | 600 seconds|
|CNAME|	*                   | @                                        | 600 seconds|
|CNAME|	email               |                        | 1 Hour     |
|CNAME|	ftp                 | @                                        | 1 Hour     |
|CNAME|	www                 | @                                        | 1 Hour     |
|MX   |	@                   | (Priority: 10)          | 1 Hour     |
|SRV  |	_autodiscover._tcp.@| 0 0 443| 1 Hour     |
|NS   |	@                   |                   | 1 Hour     |
|NS   |	@                   |                   | 1 Hour     |

I don’t want to use gmail, I want to host and to be able to send and receive email from my own server, and maybe connect to thunderbird or outlook.

Note that my problem is not if I did setup my server correctly but how to setup my server correctly to accomplish sending and receiving emails without relying on services supplied by gmail and others like it.

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi, i see that you have a problem what i had before :)

I advice you to install a free web hosting control panels like “Sentora” “CentOS Web Panel”

You can choose any of them


Hi, your question is wide to answer here, I have two suggestions for you here, hope they help you:

Hope these help.