1

I've written a little PHP script:

<?php
$phpPath = shell_exec("which php");

print "$phpPath\n";

$uid =  posix_getuid();
$userinfo = posix_getpwuid($uid);
print_r($userinfo );
print "\n";


    $to = "my_user_name@my_company_mail.com";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "do-not-reply@akamai.com";
    $headers = "From:" . $from;

    $res = mail($to,$subject,$message,$headers);

    print_r(error_get_last());
    if($res){
    echo "Mail Sent.\n";
    }else{
    echo "Mail was'nt Sent\n";

    }
?>

the thing that drives me crazy is that when I execute this script from command line it work fine : /usr/bin/php

Array ( [name] => daemon [passwd] => x [uid] => 1 [gid] => 1 [gecos] => daemon [dir] => /usr/sbin [shell] => /bin/sh )

Mail Sent.

but when I execute it from a remote browser this what I get:

/usr/bin/php

Array ( [name] => daemon [passwd] => x [uid] => 1 [gid] => 1 [gecos] => daemon [dir] => /usr/sbin [shell] => /bin/sh )

Mail was'nt Sent

any idea? 10x in advance :)

Gal Mazor
  • 100
  • 2
  • 9

1 Answers1

1

Command Line PHP and PHP doesn't use the same php.ini, please check if you have difference between them.

More information on php.ini here

Related question on SO here

Community
  • 1
  • 1
iizno
  • 744
  • 1
  • 8
  • 28
  • 1
    I've copied the the cli php.ini to lampp directory, nothing changed, all the mail configuration were the same anyway... – Gal Mazor Oct 21 '13 at 08:18