簡體   English   中英

PHPMailer不工作

[英]PHPMailer is not working

美好的一天!

我從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

我究竟做錯了什么?

提前致謝!

我不使用live.com,所以我用我的gmail帳戶測試了你的腳本,它運行良好。 您可以確保為live.com帳戶設置正確的用戶名和密碼 或者您可以嘗試設置$ 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.';
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM