0

我很难让以下代码运行:

$name = 'Kevin';
$company = 'nonw';
$website = 'none';
$email = 'my@email.com';
$phone = 'none';
$message = 'Just a test message.';

$message = "<ul>
            <li><strong>From:</strong> $name</li>
            <li><strong>Company:</strong> $company</li>
            <li><strong>Website:</strong> $website</li>
            <li><strong>Email:</strong> $email</li>
            <li><strong>Phone:</strong> $phone</li>
        </ul>
        <p>$message</p>";

$subject = '[' . $sitename . '] New contact message from ' . $name . ' ( ' . $email . ' )';

$headers = 'From: ' . $sitename . ' <' . $to . '>\r\nReply-To: ' . $email . '\r\n';

$s = mail($subject, $message, $email, $to);
if($s){
echo '<div class="msg">Your message has been sent.  Thank you for contacting us, someone will be in touch soon.</div>';
}else{
echo '<div class="err">There was an error sending your message.  Please try again later.</div>';
print_r(error_get_last());
}

我的 php.ini 中有这个:

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "/usr/sbin/sendmail -t -i -f my@email.com"

还尝试过:

sendmail_path = "/usr/sbin/sendmail -t -i"

我已经通过直接在服务器上运行它来验证服务器设置正确以发送电子邮件echo "test" | mail -s "test mail" my@email.com并且我收到了电子邮件。

会发生什么,或者更重要的是......我错过了什么?

4

1 回答 1

0

对不起大家。我在 mailconfig.ini 中拼写错误

改变"/urs/sbin/sendmail -t -i -f my@email.com""/usr/sbin/sendmail -t -i -f my@email.com"的伎俩

于 2013-03-29T18:38:00.130 回答