Shoutbox

Help with PHP mail() function... how to configure the server? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Help with PHP mail() function... how to configure the server? (/showthread.php?tid=78154)

Help with PHP mail() function... how to configure the server? by Choli on 10-12-2007 at 06:20 PM

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 ;))

RE: Help with PHP mail() function... how to configure the server? by scott2010_h on 10-13-2007 at 02:58 AM

I've never used sendmail before but I have use the guide below for setting Postfix up

http://mysql-apache-php.com/#mailserver

I had it setup in under a 30 minutes.

P.S. If you need help setting up Postfix I can try to help you.