Ubuntu – sending php mail from localhost

emailmailPHPpostfix

I have installed php, mySQL, postfix and sendmail and have set up a simple email script on my local host server. mail() returns 1 (TRUE) when I send an e-mail, however the email does not arrive at the destination.

Installation

The mail functions are part of the PHP core. There is no installation needed to use these functions.

Requirements

For the mail functions to be available, PHP requires an installed and working email system. The program to be used is defined by the configuration settings in the php.ini file.

Runtime Configuration
The behavior of the mail functions is affected by settings in the php.ini file.

Mail configuration options:

Name            Default     Description                                         Changeable
sendmail_path   NULL        Unix systems only: Specifies where the sendmail
                            program can be found (usually /usr/sbin/sendmail
                            or /usr/lib/sendmail)                               PHP_INI_SYSTEM

I found it at /usr/lib/sendmail however, I can not find the configuration file, which is where I assume my problem is, as I have not told anything which server I am using to send my mail through.

If anyone can help me I would be grateful.

Best Answer

You should not have both Postfix and Sendmail installed at the same time. Postfix is a replacement for Sendmail.

So remove Sendmail (because Postfix is easier to use):

sudo apt-get remove sendmail

Then you should reconfigure Postfix.

 sudo dpkg-reconfigure postfix

There is a very good guide here: https://help.ubuntu.com/community/Postfix

This will probably solve your problem.

Related Question