1

我写了一个小的 PHP 脚本:

<?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";

    }
?>

让我抓狂的是,当我从命令行执行这个脚本时,它工作正常:/usr/bin/php

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

邮件已发送。

但是当我从远程浏览器执行它时,我得到的是:

/usr/bin/php

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

邮件未发送

任何想法?提前 10 倍 :)

4

1 回答 1

1

命令行 PHP 和 PHP 不使用相同的 php.ini,请检查它们之间是否有区别。

更多关于 php.ini 的信息在这里

关于这里的相关问题

于 2013-10-21T07:53:28.073 回答