美好的一天!
我从Google代码页下载了PHPMailer类:http://code.google.com/a/apache-extras.org/p/phpmailer/。我正在运行:
PHP 5.2.14 (cli) (built: Jul 27 2010 10:49:36)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
在Windows 7计算机上,我使用以下测试代码:
require("PHPMailer_5.2.1/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.live.com";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = "some_email@hotmail.nl";
$mail->Password = "password";
$mail->From = "some_email@hotmail.nl";
$mail->AddAddress("some_other_email@hotmail.nl");
$mail->Subject = "Subject";
$mail->Body = "Hi!";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
我也确定密码和用户名是正确的,但是我收到以下错误:
Message was not sent.Mailer error: The following From address failed: some_email@hotmail.nl
我做错了什么?
提前致谢!
答案 0 :(得分:2)
我不使用live.com,所以我用我的gmail帐户测试了你的脚本,它运行良好。你可以确定,你有correct Username and Password set for your live.com account。或者您可以尝试设置 $ mail-> SMTPSecure ='tls'; 这适用于gmail:
require("PHPMailer_5.2.1/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Username = "yourNickname@gmail.com";
$mail->Password = "yourPassword";
$mail->From = "some_email@hotmail.nl";
$mail->AddAddress("receiver@server.ext");
$mail->Subject = "Subject";
$mail->Body = "Hi!";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}