dsfds4551 2014-02-10 07:20
浏览 37

电子邮件未送达,代码导致内部服务器错误

I have code to send message via php mailer to my email address.

I get server error but i don't receive any message on inbox or spam folder.

Please help and , and this is my code

<?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();
}

?>
  • 写回答

1条回答 默认 最新

  • duanfenhui5511 2014-02-10 07:23
    关注

    You are using

    if(!$mail->Send())
    {
        echo "Done";
    }
    

    This means that if mail is not send, it will echo out Done. Change the condition to:

    if($mail->Send())
    {
        echo "Done";
    }
    else
    {
        echo $mail->ErrorInfo;
    }
    

    Now you will see the error message

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题