2016-10-24 17 views
1

私たちは、以下に示すようにPHPコードスニペットを使用してOutlookメールを送信しようとしています。 しかし、localhostを使ってコードを実行すると、空白の画面しか表示されません。メールは送受信されません。 誰かが私たちをここで助けることができますか?前もって感謝します。PHPスクリプトを使用してOutlookでメールを送信すると、空白の画面が表示されます

Outlook.php

<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title> MY MAIL </title> 
</head> 
<?php 
$account="[email protected]"; 
$password="****"; 
$to="[email protected]"; 
$from="[email protected]"; 
$from_name="ABC"; 
$msg="Hello"; 
$subject="Hello World"; 

include("phpmailer/class.phpmailer.php"); 
$mail = new PHPMailer(); 
$mail->IsSMTP(); 
$mail->CharSet = 'UTF-8'; 
$mail->Host = "smtp.live.com"; 
$mail->SMTPAuth= true; 
$mail->Port = 587; 
$mail->Username= $account; 
$mail->Password= $password; 
$mail->SMTPSecure = 'tls'; 
$mail->From = $from; 
$mail->FromName= $from_name; 
$mail->isHTML(true); 
$mail->Subject = $subject; 
$mail->Body = $msg; 
$mail->addAddress($to); 
$mail->SMTPDebug = 1; 
if(!$mail->send()){ 
echo "Mailer Error: " . $mail->ErrorInfo; 
}else{ 
echo "E-Mail has been sent"; 
} 
?> 
<body> 
</body> 
</html> 
+0

"Outlookメール" とは何であるを確認することができますか?私は "電子メールメッセージ"を知っている。 – arkascha

+0

httpサーバーのエラーログファイルを調べ始めます。ここでは、_guess_またはここで質問する代わりに、問題が何であるかを簡単に_read_できる場所です。あなたはそのログファイルを監視せずにPHPでプログラムできません! – arkascha

答えて

0

あなたはパラメータを設定することで、あなたのメーラをデバッグすることができ、このPHPのメールコード

<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title> MY MAIL </title> 
</head> 
<?php 
$account="[email protected]"; 
$password="****"; 
$to="[email protected]"; 
$from="[email protected]"; 
$from_name="ABC"; 
$msg="Hello"; 
$subject="Hello World"; 

include("phpmailer/class.phpmailer.php"); 
$mail = new PHPMailer(); // create a object to that class. 
$mail->IsMail(); 
//$mail->IsSendmail(); 
$mail->Subject = $subject; 
$mail->From = $from; 
$mail->FromName = $first_name." ".$surname; 
$mail->AddAddress($to); 
//$mail->AddBCC('[email protected]'); 
$mail->Body = $mailBody; 
$mail->IsHTML(true); 
if(!$mail->send()){ 
echo "Mailer Error: " . $mail->ErrorInfo; 
}else{ 
echo "E-Mail has been sent"; 
} 
?> 
<body> 
</body> 
</html> 
0

を試してみてください。

// enables SMTP debug information (for testing) 
$mail->SMTPDebug = 1; // 1 = errors and messages 
OR 
$mail->SMTPDebug = 2; // 2 = messages only 

//Send email 
if(!$mail->Send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent!"; 
} 

あなたはここに完全な例

PHPMailer debug example code

関連する問題