Hi,
I'm trying to use the
mail function of PHP but it doesn't seem to work in my server. Let me explain that:
I wrote this code:
code:
$dst = "someone@example.net";
$subject = "test";
$msg = "bla bla bla...";
$hdr = "From: someoneelse@example.com\r\nReply-To: someoneelse@example.com\r\nX-Mailer: PHP";
$ret = mail($dst, $subject, $msg, $hdr);
Some time ago I tested that code in a public server (one of those sites where you pay for a hosting and everything is installed (apache, php, ...)) and it worked correctly. The mail was sent to someone@example.net with the sender someoneelse@example.com.
Now, I want to set up my own server. It's a Linux (Ubuntu 6) machine with Apache 2 and PHP 5. As it says in www.php.net I've also installed
sendmail. So in this machine, the code above does not work. The mail() function returns true, but the mail isn't sent.
I've been investigating a bit and I've discovered that mail() calls sendmail (as expected) but sendmail can't send the message. I think that sendmail tries to open a socket to localhost:25 (where there's another sendmail process listening to) but at the end, the message is not sent.
I've tried to modify php.ini without any luck. Also, I don't know how to configure sendmail properly. Any help with this, please?
In my tests, I've deduced that either PHP should connect to example.net:25 to send the email, or the sendmail daemon (the one listening to localhost:25) should do that, but none of those things happens.
So, what can I do?
Thanks for the help. (if you need any more details, just ask me
)