Linode Forum
https://forum.linode.com/

Weird behaviour with sendmail, Apache and PHP
https://forum.linode.com/viewtopic.php?f=11&t=3712
Page 1 of 1

Author:  dcelasun [ Thu Dec 04, 2008 2:43 pm ]
Post subject:  Weird behaviour with sendmail, Apache and PHP

What I'm trying to do is to simply make the mail() function of PHP work flawlessly.

I've installed sendmail with
Code:
apt-get install sendmail

It installed without any problems and auto-configured everything.

The weirdness starts here. I've created a simple php file to test it.

The contents are as follows:
Code:
<?php
$to ='me@example.com';
$subject = 'Hi!';
$message = 'Sample Message';
$headers = 'From : you@somedomain.com'."\r\n".
'Reply-To: someone@somedomain.com';

if (mail($to,$subject,$message,$headers)) {
print "Success!";
}else{
print "Failed :(";
}

?>


Now, the mail successfully arrives at the destination, no problem there. But the php script never gets terminated. It just keeps running and running until the process is automatically killed. Then the page displays a "500 Internal Server Error".

I do know a few things about sendmail, but never encountered an error like this before. Any ideas? Thanks!

Author:  dcelasun [ Thu Dec 04, 2008 4:35 pm ]
Post subject: 

I've found the solution and I'm writing it here for future reference.

The problem was that I haven't set an FQDN (Fully Qualified Domain Name) in /etc/hosts. The file's first two lines were like this:
Code:
127.0.0.1 localhost
127.0.0.1 [your host name]


I've changed it to this:
Code:
127.0.0.1 localhost localhost.localdomain [your host name]
127.0.0.1 [your host name]


Then I've executed sendmailconfig and voila! Everything worked flawlessly!

Page 1 of 1 All times are UTC-04:00
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/