How to set up server to send emails using mail() - a php function?

March 23, 2015 12.3k views
PHP Email Ubuntu

Hi, we've installed all programs we need in our droplet and we are using it to develop a project.
So far we've set up in our ubuntu droplet: nginx, php 5 and ruby.
We've installed php 5, we followed some tutorials seems everything is set up, but when we use the command mail() in a php program inside our server, it seems to work, but the email is never received.
Something is wrong....we think there may be something we forgot to set up, since we are used to use hosting services from companies that offer everything already set up within the infrastructure. could you please help us?
Thank you!

2 Answers

You will need an MTA to process outgoing mail on your server. You can use sendmail or postfix (I recommend postfix). To install postfix:

apt-get update;
apt-get install postfix;

Thanks for your help! great! All we've gotta do is run those commands? or there's some extra configuration we'll need to do?

Have another answer? Share your knowledge.