2012-04-27 13 views
2

現在、私はPHPmailerを使用してメールを送信しようとしています。ここで私はSSLを試してみた電子メールを送信するためにHotmailに接続するPHP?

​​

以下のコードがあり、phpmailerの持つsmtp.live.com用ポート587、なぜそれが動作しませんか?

"SMTPエラー:SMTPホストに接続できませんでした。メーラーエラー:SMTPエラー:SMTPホストに接続できませんでした。

私はtelnet smtp.live.com 25,587できません。 smtp.gmail.comなど。何をすべきですか? :(

+0

「smtp.live.com」に「telnet」できないのはどういう意味ですか?あなたはどんなエラーを出していますか? – icktoofay

+0

ポート25でホストへの接続を開けませんでした。通信失敗。 – user127886

+0

@ user127886、あなたのホストはおそらくそれらのポートをブロックしています。それは一般的です。 – Brad

答えて

0

ポート587は私のために働いた。

IsSMTP()を実行する必要はありません。それは、例外がスローされますようにそれをコメントアウトします。それはあなたの問題を解決するかどうか

いけないの答えとしてそれをマークすることを忘れ:)

+0

あなたの答えは間違っています – Julian

2
<?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 = "[email protected]";  // hotmail username 
$mail->Password = "useyourownpassword";   // hotmail password 
$mail->SetFrom('[email protected]', 'First Last'); 
$mail->AddReplyTo("[email protected]","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 = "[email protected]"; 
$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!"; 
} 

?> 
+0

あなたの返信ありがとう – Talha

2

タルハの回答は私のために働いています。 $ mail-> IsSMTP();とコメントしてみてください。私はこの部分を$ mail-> Port = 587とコメントしました。

関連する問題