Easy Way To Install Postfix On Ubuntu Server
|Most recent CMS (Content Management System), blogging platforms, and nowadays’ scripts have a feature to send email either for notifications, account confirmation, etc. Let’s say WordPress, this widely used blogging platform itself will send emails to Admin telling for new comment posted, new user registration, and messages submitted via contact form page. I tell you already how to setup a working live server to host your websites and blogs in it. And that’s including how to install web server of your choice (Apache or Nginx), install MySQL server, and install perfect build of PHP. If you’ve followed my guide from the beginning, your server should now already be online and ready to host your website files and database. You can also install your desired CMS like WordPress on it. But this will not have so much fun if you don’t install Postfix.
Without a working mail server your site’s visitors would never be able to send you message via contact form, you will also not be able to know each time new comment posted or waiting your moderation, and so on.
I can say this guide as an essential knowledge every newbie should know.
p.s: Every time I say “server” it can refer to both VPS or Dedicated server.
Requirements
- A working server running Ubuntu OS but Debian should also be similar. In this guide I use Ubuntu 12.04. You can read more about my playground server here. In this case I assume you’ve already setup a live online server to host your file. Otherwise, read below tutorials;
- Either Apache or Nginx web server should already be installed. Read:
How to install Apache and PHP5
How to install Nginx and PHP5 - MySQL server. Read: How To Install MySQL Server
- As usual, you’ll also need our favorite app to access your sever via SSH. For me, I prefer to use Putty. You can download Putty and read guide how to use Putty here.
How To Install Postfix
Step 1 – Login to your server via SSH. If you’ve followed my previous guide about essential Ubuntu setup, you may have to login using your username because root login has been disabled. If you do so, once logged in simply type su, hit Enter on your keyboard, then type your root password in.
Step 2 – Type this command syntax to get Postfix installation files:
apt-get install postfix
If it asks you: “Do you want to continue” simply answer yes by typing Y then hit Enter.
Step 3 – The installer script will then display some information about available configurations. Read on then select “OK”.
Step 4 – Once you hit OK, it will then ask you which Postfix configuration you wish to use. In this case you can simply select “Internet Site“. Use Up and Down arrow to navigate, then use Right and Left arrow to select the “OK” part.
Step 5 – Now you have to define your server’s fully qualified domain name (FQDN). It is up to you. You can use something like mail.yourserver.com, host.yourservercom, server.yourserver.com or even the extreme one like ghost.yourserver.com.
Step 6 – Once all those steps done, all you have to do is wait the process to finish. It should take less than a minute. You’ll also get a message saying..
Step 7 – To make sure all configurations loaded properly, it is also better to restart Postfix service via this command:
/etc/init.d/postfix restart
That’s it. Once you’ve uploaded all files of your website to the server and installed the script you want correctly, do not forget to give it a test. In WordPress you can also try a free plugin called “Check-Mail”. This free plugin allows you to test if your WordPress installation is sending emails correctly by sending a test email to an address of your choice. Enjoy..
Do not hesitate to reply comment asking something or sharing what you got during your play with your server.
Your tutorials on wordpress and apache installations were fantastic. I’ll give this a try as well. Thank you…
Hi ServerMom!
Great guide, it helped me a lot.
An addition if I may for those who can’t send emails to their own domain name from WordPress…
If your domain is http://yourdomain.co.uk and you want to send notification emails from WordPress to email@yourdomain.co.uk, you might find that they don’t arrive, but emails sent to addresses on other domains like email@gmail.com work fine.
This is probably because Postfix is trying to deliver the emails destined to @yourdomain to itself.
You need to tell Postfix that it isn’t the destination for that domain.
Use the following command to run the configuration again:
sudo dpkg-reconfigure postfix
Follow the prompts and just hit the defaults or reinsert your config, but when you see it ask:
Please give a comma-separated list of domains for which this machine should consider itself the final destination.
…make sure that “yourdomain.co.uk” is NOT listed. If it is, delete it and complete the config. At the end of the config, Postfix should restart itself so go ahead and try to send an email to email@yourdomain.co.uk and it should work – at least it did for me!
If it doesn’t send emails at all then you may need to define the sendmail_path in your php.ini file, so…
If you followed the previous guides here at ServerMom then go to http://yourdomain.co.uk/viewinfo.php to view your php info. Use ctrl+f and type in ‘sendmail_path’ without the quotes. You should see the path to sendmail for your system.
Copy the path or make a note of it.
Open your php.ini file with nano (on Ubuntu its in /etc/php5/apache2/php.ini) and hit ctrl+w and type in ‘sendmail_path’ without the quotes and hit enter, where you’ll be taken to the right line to edit the path. Make sure that there is no semi-colon ( ; ) at the start of the line and after the = sign, copy/write in the sendmail_path you got from the viewinfo.php page earlier. Hit ctrl+o to write the changes to the file and hit enter if it asks for the file name. Then hit ctrl+x to exit.
Hope that helps someone as it solved a few annoyances for me!
ola e obrigado
Bom se puder me ajudar fico grato
na parte que e para digitar a parte
apt-get instalar postfix
no lugar de apt-get tenho que colocar a
yum instalar postfix
ate ai tudo bem chama a instalação
mas não perguntar: “Você quer continuar” simplesmente responder sim, digitando Y , em seguida, pressione Enter.
E não pode para dar sim
então não abre a tela rosa
o que fazer pode me ajudar obrigado fico esperando
esta ando este erro ai
Error: package: 2:postfix -2.6.6-6.e16_5.x86_64 (updates) Requires: libmysqlclient.so.16 90 64 bit
Hi, After the installation, WordPress notification emails are going to spam. How to solve this problem ??
you should setup rdns entry for your ip. usually it can be done via solusvm