简体   繁体   中英

PHPMailer is not working

Good day!

I downloaded PHPMailer class from the Google code page: http://code.google.com/a/apache-extras.org/p/phpmailer/ . I'm running this with:

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

On a Windows 7 machine and I'm using the following test code:

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.';

I'm also sure that the password and the user name are correct, but I get the following error:

Message was not sent.Mailer error: The following From address failed: some_email@hotmail.nl

What am I doing wrong?

Thanks in advance!

I don't use live.com, so I tested your script with my gmail account and it worked well. You can make sure, you have the correct Username and Password set for your live.com account . Or you can try to set $mail->SMTPSecure = 'tls'; This works well with 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.';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM