user2417713
user2417713

Reputation: 167

Configure sendmail (Fedora) to work on localhost using the php mail function

I am using the following code to send an email to my gmail account:

$to      = 'My gmail address';
$subject = 'subject here';
$message = 'Test PHP email using mail()';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if( !mail($to, $subject, $message, $headers) ) echo "Error with sendmail mail()";
else echo 'Message has been sent';

Running the script returns "Message has been sent", but I never receive the email (checked spam).

My OS is Fedora release 20 (Heisenbug) and the phpinfo function returns the following:

PHP                 Version: 5.5.23
System:             Linux localhost.localdomain 3.18.9-100.fc20.x86_64
Configuration File: /etc/php.ini
Apache Version:     Apache/2.4.10 (Fedora) PHP/5.5.23
Hostname:Port:      localhost.localdomain:0
DOCUMENT_ROOT:      /var/www/html

The following values are same for both Local & Master:

sendmail_from:      no value
sendmail_path:      /usr/sbin/sendmail -t -i
SMTP:               localhost
smtp_port:          25

I have installed both sendmail & sendmail-cf. These are the DAEMON_OPTIONS / LOCAL_DOMAIN settings in the sendmail.mc file:

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
LOCAL_DOMAIN(`localhost.localdomain')dnl

Please help.

Upvotes: 0

Views: 1397

Answers (1)

symcbean
symcbean

Reputation: 48357

Your diagnosis is somewhat lacking. Check your MTA logs and the mailq to find out what happened next.

Sendmail is a very cool tool but I would not recommend its use by someone with limited experience/in a context like this. Normally I would suggest nullmailer but that doesn't do local delivery (last time I checked) hence I suggest you think about using postfix as the MTA.

Upvotes: 1

Related Questions