Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Ubuntu Server 12.04 use to run my Webapp. I assume my Webapp wrote in PHP5, run-time enviroment is LAMP, domain is When visitor register account on, website will send a confirm email automatically. But my system cannot send mail to user's inbox.

I don't think the code of has error, because it uses the built-in function mail() and runs well on and I have tried installing sendmail by using the command sudo apt-get install sendmail. But nothing changed.

Can you help me configure this system so that can send mails to users automatically, without using a 3rd party email service like as Gmail or Hotmail, just using the mail() function; all aspects of the problem, about:

  • Config DNS records
  • What are app/packages need to install on Ubuntu Server 12.04
  • Config router: open port, NAT,...
  • Config Apache, PHP.ini or other
share|improve this question
First of all it is useful knowing what is the error. So search in logs of postfix / sendmail / etc. Immediatly after sending a mail from website type: tail -50 /var/log/maillog this is the path on CentOS server, on some distros maybe: /var/log/mail.log ---------- After check a thing: Where is your server? Some dedicated server hostings NOT permit outbound emails or limit it (SMTP sockets in general). (For example Amazon AWS after a certain amount of outgoing SMTP calls, block you as a spammer). Check your server hosting for this information. – elijabaley Aug 21 '13 at 9:09
sendmail isn't exactly the most intuitive mail server around. Try Postfix or Exim instead; I prefer Postfix myself, but both are reasonably easy to configure and pretty sane by default. Also, check your system logs to see what the error might be; chances are there's something pretty clear in either /var/log/messages or one of /var/log/mail*. – Michael Kjörling Aug 21 '13 at 9:14
That said, if you don't feel up to the task of actually maintaining that mail server properly, I'd strongly recommend you just configure PHP to use your ISP's mail server instead. I forgot the exact configuration directive but it should be mentioned in the PHP manual under mail() or something like that. – Michael Kjörling Aug 21 '13 at 9:16
up vote 2 down vote accepted

My suggestion would be to remove sendmail (it's not a good nor light MTA) and replace it with postfix, when you install postfix using ubuntu's normal software installation process (either apt cli or Ubuntu Software Center) it will ask what kind of mail server you want to install, the correct answer depends on whether the machine is a full server or just a development/staging environment.

If it's a normal server use "internet site" if it's a development environment use "Internet with Smart host" and specify ask your Internet provider or Network Administrator for your smtp server details.

If you need to change postfix's configuration most of it will be in /etc/postfix/, however because because you don't want your server becoming an open relay, after applying any configuration changes use to test that it's not.

Given default php.ini settings you should then be able to send out emails via the mail() php function.

share|improve this answer
thank you, I'm in checking :D – Davuz Aug 22 '13 at 3:31
Thank @fenix so much! Install Postfix and mail() work perfectly. But with some domain (as my website), email sent to user will be marked as SPAM – Davuz Aug 23 '13 at 17:58
Are you hosting this server from your home connection? A lot of home connection IP addresses get automatically treated as spam, especially if you're on a dynamic IP address. If so, ask your provider about a static IP address, this will probably incur a small extra charge, if you're hosting from a VPS, Shared or Dedicated server, check your servers IP address with – Aaron Tate Aug 24 '13 at 7:15

You should not only install sendmail, but also configure it or other MTA. If you have relay for sending mail's, you should configure MTA to use it. If you haven't relay, you should also setup some DNS-records to prevent your messages dropped as spam.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.