我有代码通过php邮件发送消息到我的电子邮件地址。
我收到服务器错误,但我没有在收件箱或垃圾邮件文件夹中收到任何邮件。
请帮忙,这是我的代码
<?php
require_once("class.phpmailer.php");
include("class.smtp.php");
try {
$sname= "moda"; //
$smail="nase25r@yahoo.com"; // sender email
$rname="anyone"; //
$rmail="nalshlwan@kacst.edu.sa"; // receiver email
$sub="supject";
$body="ggggggggggggggggggggggggggggggggggggggggggggggggggg";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "TLS";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = ""; // my gmil email
$mail->Password = ""; // my gmail password
$mail->AddReplyTo($smail,$sname);
$mail->AddAddress($rmail, $rname);
$mail->From = $smail;
$mail->FromName = $sname;
$mail->Subject = $sub;
$mail->MsgHTML($body);
$mail->IsHTML(true);
if($mail->Send()) {
echo "Done";
}
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>
答案 0 :(得分:0)
您正在使用
if(!$mail->Send())
{
echo "Done";
}
这意味着如果没有发送邮件,它将回显完成。将条件更改为:
if($mail->Send())
{
echo "Done";
}
else
{
echo $mail->ErrorInfo;
}
现在您将看到错误消息