Jump to content

Mail() behaves differently in CLI and web version


cybernga

Recommended Posts

Hello,

I'm trying to get mail() to work as intended (mail is required unfortunately). All code is written in a Linux box with a local Postfix installation that works like a charm ( can send mail through command line ).

Environment:
PHP Version 4.4.2-1build1
Apache 2.0
Ubuntu Linux

The code is as follows :
[code]
<?php
// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
if(mail('cybernga@localhost','Subject','Message')) {
        print "Mail sent";
    } else {
        print "Mail not sent";
}

?>
[/code]

The above code obviously sends the mail to a local user. The weird part is that when the above code is run through the command line it works just fine, but when it's run from the browser the mail never reaches Postfix (nothing logged)... any ideas ?

thank you in advance for any answers :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.