我已经这样做了好几个小时并且无法让它工作,教程中的许多评论说它的功能就像一个魅力,但我无法真正做到这一点.
我已经完成了所有步骤http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/并阅读了所有其他用户遇到的问题的评论,并使用了回复的解决方案.
我在apache错误日志中看到的是这个
[Tue Nov 27 05:19:47 2012] [notice] Parent: Created child process 4120
[Tue Nov 27 05:19:47 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Child process is running
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Acquired the start mutex.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting 64 worker threads.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting thread to listen on port 80.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting thread to listen on port 80.
Run Code Online (Sandbox Code Playgroud)
我也在我的另一台计算机上尝试过,它有相同的错误日志.我已经禁用了防火墙,并严格按照教程中的步骤操作.
对不起,上一个答案.感谢大家的建议,以改善我的答案.这是我的答案:phpmailer有一个名为class.phpmailer.php的文件.然后在function smtpmailer($to, $from, $from_name, $subject, $body)代码中如下:
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = 'gmailusername';
$mail->Password = 'gmailpassword';
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->IsHTML(True);
$mail->Body=$body;
//$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
Run Code Online (Sandbox Code Playgroud)
然后只需调用您想要的函数:
smtpmailer($to, $from, $headers, $subject, $message);
哦,在此之前确保启用了php_openssl扩展.
我希望我的回答很有帮助.:)