有时候调试很忙......我如何处理mail
函数?我似乎需要更改一些设置,但我不知道如何处理它们:当我尝试在我的论坛上发布回复时,这个错误突然出现:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\mysite\forum part two\post_reply_parse.php on line 72
第72行的代码就是这个
mail($to, $subject, $message, $headers);
我的邮件代码是这样的
$email = '';
$email = substr($email, 0, (strlen($email) - 2));
address with your domain at the end
$to = "";
$from = "";
// $bcc is the list of emails that will be sent out as blind carbon copies
$bcc = $email;
$subject = "YOUR_SUBJECT_HERE";
$message = "YOU MESSAGE CONTENT HERE";
$headers = "From: $from\r\nReply-To: $from";
$headers .= "\r\nBcc: {$bcc}";
// Send out the email
mail($to, $subject, $message, $headers);
我不想忽略这个错误,我很乐意学习如何修复它。
答案 0 :(得分:4)
默认情况下,PHP将在Linux / Unix计算机上使用sendmail
,因为它通常是可用的邮件服务。
mail()
,您需要安装本地SMTP服务器或配置PHP安装以通过其他SMTP服务器中继邮件。
注意:我没有亲自使用过,因为我倾向于在Linux / Unix机器上进行开发,但这可能对您有用:http://www.hmailserver.com/