Installation of Postfix and Dovecot Mail Server on Ubuntu and Postfix will not start

dovecotemail-serverpostfixubuntu-14.04

Information on the Mail Server Installation Process Followed…

Hello I have a server with DigitalOcean that I am trying to install an email server on so I can add and manage email accounts. This is my first time trying to install these servers as past projects had a CP that automatically installed and configured the mail servers.

Software to install or configure or both onto my Ubuntu 14.04 VPS:

  • MySQL (already installed for my webserver)
  • Postfix
  • Dovecot

I have to say it's one of the hardest, or most time consuming processes I have attempted on a Ubuntu server to date.

Luckily I found the best tutorial I have seen online for setting up this mail server combination of Postfix, Dovecot, with MySQL to hold the EMail Account info at this URL on Linode… https://www.linode.com/docs/email/postfix/email-with-postfix-dovecot-and-mysql

It's a 45 step tutorial that is very detailed as far as what commands to run and which config files to modify and the values to add and remove from these config files. It's very new user friendly and doesn't leave much guessing which is great with such a task as this Mail Server combination of software..

I spent probably 5 hours! Going through the steps, making sure it was all done to the T perfectly and it seemed to have worked as all my test that the tutorial has you do such as making sure that Postfix is pulling email accounts, alias, and users/password from the MySQL tables that I created. It all seemed to work up until that part.

Once I got to the last step, it has you send an email from another account/server/service to one of your newly created email accounts to test that the mail server is working for receiving email. I went ahead and sent my new email address linked to my domain name from my Gmail account and the next day I received the bounce email back on my Gmail for a failed email delivery! It seems my efforts have only partially worked and the mail server is not working! I say partially worked because as I mentioned Postfix was returning the proper stuff from MySql so I know that some of it is set up correctly and functioning but somewhere near the end of the process it is wrong or not working.

1 thing that I was slightly confused about is in that tutorial and many others where they mention using an (FQDN) Fully Qualified Domain Name AND the Servers Localhost name. Now where I am confused is that all the emaples I always see show real Domain names example.com for these values however mine is not a real domain name…

My FQDN value is set to: Apollo-Web-Studio

My servers Localhost value is set to: Apollo-Web-Studio

So as you can see my values are not set to a .com style Domain name and instead just a name. Could this be part of the problem??

The server does have a domain name, it's just not set as the FQDN and Localhost values.


Debugging the Mail Servers

So to start trying to track down what is and is not working I then referred to the article linked to from the first tutorial URL above. It has a link to a Troubbleshooting atutorial located here…
https://www.linode.com/docs/email/postfix/troubleshooting-problems-with-postfix-dovecot-and-mysql/

I ran in command line: service dovecot status

The result was not pretty: * postfix is not running

I then ran service postfix restart and the result was this:

 * Stopping Postfix Mail Transport Agent postfix
   ...done.
 * Starting Postfix Mail Transport Agent postfix
   ...done.

So then again I check to make sure it did start and I get this…
service postfix status = * postfix is not running

As you can see a restart did not actually start Postfix =(

So moving on anyways to check the status of Dovecot. I ran the same commands but for Dovecot…

service dovecot status and I get better results with this one… dovecot start/running, process 7660 so it appears that it is running just fine as a running service at least!

So I have not proceeded any furthor since I cannot seem to get Postfix running.

I then checked the log file that it mentions to check located here /var/log/mail.log results below =

Dec 24 00:39:59 Apollo-Web-Studio postfix/master[1060]: warning: master_wakeup_timer_event: service pickup(public/pickup): No such file or directory
Dec 24 00:40:25 Apollo-Web-Studio postfix/smtpd[7800]: fatal: open lock file pid/inet.smtp: cannot create file exclusively: No such file or directory
Dec 24 00:40:26 Apollo-Web-Studio postfix/master[1060]: warning: process /usr/lib/postfix/smtpd pid 7800 exit status 1
Dec 24 00:40:26 Apollo-Web-Studio postfix/master[1060]: warning: /usr/lib/postfix/smtpd: bad command startup -- throttling

I then checked log file /var/log/mail.err which basically just had these 2 error lines repeated over and over and over so I will just post the 2 lines that it repeats in the file below =

Dec 24 00:34:03 Apollo-Web-Studio postfix/master[7593]: fatal: bind 0.0.0.0 port 25: Address already in use
Dec 24 00:34:19 Apollo-Web-Studio postfix/smtpd[7613]: fatal: open lock file pid/inet.smtp: cannot create file exclusively: No such file or directory

Port Trouble?

In the log file entries posted above in the debugging section you might of seen the line that mentions in the mail.err log file…

Dec 24 00:34:03 Apollo-Web-Studio postfix/master[7593]: fatal: bind 0.0.0.0 port 25: Address already in use  

So it is saying port 25: Address already in use. If I go back to the tutorial that I followed for the installation process I search for Port 25 and I find it!

It says this:

You should use Port 993 for secure IMAP, Port 995 for secure POP3, and Port 25 with SSL for SMTP.

Looking back at the tutorial I followed for the installation, every mention of using and setting Port 25 are all in the sections for configuring Postfix and since that is the server that seems to not want to start now, would you think this could be my main problem?

I also ran this in terminal to see what had tied up Port 25 alread…

sudo netstat -lnp |grep :25  

The results:

tcp    0  0 0.0.0.0:25  0.0.0.0:*   LISTEN
1060/master
tcp6   0  0 :::25     :::*        LISTEN
1060/master

I will also need some assistance/info on fixing the Port 25 problem. I really know very little about configuring Linux servers, my knowledge is pretty much limited to years of following tutorials like this one when I need to install software and mostly just setting up LAMP servers for websites!

I feel like I am really close to getting this mail sever working though and would be greatly appreciative if someone can help me to get it working 100%. I have put almost 8 hours into this so far, just on the mail server! SO besides really needing it, I also have invested all that time and have it 90% working/setup I believe so I can't quit and give up now!

Please help some Linux Guru thank you

Best Answer

I got it working 100%

I considered deleting this questions since it had no comments or answers but after spending nearly 8 hours on setting up this mail server...I just couldn't do it as this might very well help others searching for the answer to this problem. My searches revealed that many people have had this problem and there isn't many answers to it! Or at least the good answers are difficult to find sometimes.

So here it is...

Reboot Ubuntu = No more Port 25 collision/blockage => Email being sent and received from my domain configured email addresses and accounts all working as you would want it to now!

Thats it, no joke...a REBOOT!

sudo reboot

Hopefully this saves someone else hours and headaches, good luck

Related Topic