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 :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.