PHP邮件发送问题

时间:2013-03-29 18:24:29

标签: phpmailer php

我很难获得以下代码:

$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上运行,然后收到了电子邮件。

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

1 个答案:

答案 0 :(得分:0)

抱歉,伙计们。我在mailconfig.ini

中拼错了

"/urs/sbin/sendmail -t -i -f my@email.com"更改为"/usr/sbin/sendmail -t -i -f my@email.com"可以解决问题

相关问题