我试了一下phpmailer ,用163的smtp服务器能够正常发邮件,后来我在本机(xp)安装了smtp服务,想试试从本机直接发邮件,但一直没成功,请问应该怎么设置?
<?php
/**
* Simple example script using PHPMailer with exceptions enabled
* @package phpmailer
* @version $Id$
*/require '../class.phpmailer.php';try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled $body             = file_get_contents('contents.html');
$body             = preg_replace('/\\\\/','', $body); //Strip backslashes $mail->IsSMTP();                           // tell the class to use SMTP
$mail->SMTPAuth   = false;                  // enable SMTP authentication
$mail->Port       = 25;                    // set the SMTP server port
$mail->Host       = "localhost";        // SMTP server
$mail->Username   = "www";     // SMTP server username
$mail->Password   = "www";            // SMTP server password// $mail->IsSendmail();  // tell the class to use Sendmail $mail->AddReplyTo("[email protected]","First Last"); $mail->From       = "[email protected]";  //一直是这句出错
$mail->FromName   = "First Last"; $to = "[email protected]"; $mail->AddAddress($to); $mail->Subject  = "First PHPMailer Message"; $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; 
                                                                          // optional, comment out and test
$mail->WordWrap   = 80; // set word wrap $mail->MsgHTML($body); $mail->IsHTML(true); // send as HTML
 
$mail->Send();
echo 'Message has been sent.';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>说明:执行时老是报错The following From address failed: [email protected];另外,源文件中$mail->IsSendmail();这一句我执行起来也老是报错,我在网上看到说注释掉就好了,于是我就注释掉了,的确好了,但我不明白,如果这句话没用,那么为什么会出现在这里?