PHP для подключения к Hotmail для отправки электронной почты?

В настоящее время я пытаюсь использовать PHPmailer для отправки электронной почты. Вот коды ниже

<?php require("phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); // ---------- adjust these lines --------------------------- ------------ $mail->Username = "(username@hotmail.com)"; // your hotmail user name $mail->Password = "password"; $mail->AddAddress"(username@hotmail.com)"; // recipients email $mail->FromName = "test"; // readable name $mail->Subject = "Subject title"; $mail->Body = "Here is the message you want to send to your friend."; //----------------------------------------------------------------------- $mail->Host = "smtp.live.com"; // GMail $mail->Port = 25; $mail->IsSMTP(); // use SMTP $mail->SMTPAuth = true; // turn on SMTP authentication $mail->From = $mail->Username; if(!$mail->Send()) echo "Mailer Error: " . $mail->ErrorInfo; else echo "Message has been sent"; ?> 

Я пробовал SSL, порт 587 для smtp.live.com с PHPMailer, почему он не работает?

Ошибка: «Ошибка SMTP: не удалось подключиться к узлу SMTP. Ошибка Mailer: ошибка SMTP: не удалось подключиться к узлу SMTP».

Я не могу telnet smtp.live.com 25,587. smtp.gmail.com и т. д. Что мне делать? 🙁

 <?php //error_reporting(E_ALL); error_reporting(E_STRICT); date_default_timezone_set('America/Toronto'); require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); $body = file_get_contents('contents.html'); $body = eregi_replace("[\]",'',$body); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "tls"; // sets the prefix to the servier $mail->Host = "smtp.live.com"; // sets hotmil as the SMTP server $mail->Port = 587; // set the SMTP port for the hotmail server $mail->Username = "useyourownemail@hotmail.com"; // hotmail username $mail->Password = "useyourownpassword"; // hotmail password $mail->SetFrom('yourname@yourdomain.com', 'First Last'); $mail->AddReplyTo("name@yourdomain.com","First Last"); $mail->Subject = "PHPMailer Test Subject via smtp (hotmail), basic"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = "anemail@domain.com"; $mail->AddAddress($address, "John Doe"); $mail->AddAttachment("images/phpmailer.gif"); // attachment $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?> 

Ответ Талхи работает для меня. Попробуйте прокомментировать $ mail-> IsSMTP (); и я также прокомментировал эту часть $ mail-> Port = 587;

порт 587 работал для меня.

нет необходимости запускать IsSMTP (). Прокомментируйте это, поскольку он будет генерировать исключения.

Не забывайте отмечать это как ответ, если он решает вашу проблему 🙂