dongzhi6382 2017-07-14 14:20
浏览 38

PHPMailer不起作用,页面变白

I'm trying to send an email with PHPMailer, but everytime I press to send, the page turns white. I tried to search in the error_log but nothing appeared inside. By the way, I'm using ajax, all the plugins are included and working.

This is the code I have:

$.ajax({
            type: "POST",
            url: "cod_ajax/enviar_email.php",
            data: "nome="+nome+"&last="+last+"&email="+email+"&assunto="+assunto+"&texto="+texto,
            success:function(e){
                document.write(e);
                $("#envia_email").prop("disabled", true);
              setInterval(function(){
                $("#envia_email").html("Email Enviado com sucesso! Recarregue a página para enviar outro!");
              }, 2000);
                $(".erros").fadeOut(0);
                $("#name").val("");
                $("#last").val("");
                $("#email").val("");
                $("#assunto").val("");
                $("#texto").val("");
            }
        })

All variables are right, nothing is empty and receive well the information. This is my ajax file:

if(isset($_POST['name'])){
$nome=$_POST['nome'];
$last=$_POST['last'];
$email=$_POST['email'];
$assunto=$_POST['assunto'];
$texto=$_POST['texto'];

require '../mail/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('b_daniel_18@hotmail.com');
$mail->addAddress('b_sem_l@hotmail.com');
$mail->Subject  = 'First PHPMailer Message';
$mail->Body     = 'Hi! This is my first e-mail sent through PHPMailer.';
if(!$mail->send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}
}

I didn't use the variables because it didn't work so I tried adding information manually, still didn't work.

UPDATE

Removed the if(isset($_POST['name'])) and I can see the errors now. It doesn't send, appears Mailer error: Could not instantiate mail function.

  • 写回答

2条回答 默认 最新

  • dongyuan9149 2017-07-14 14:27
    关注

    You mistyped your form variable name in the php file. Change

    if(isset($_POST['name']))
    

    To:

    if(isset($_POST['nome']))
    
    评论

报告相同问题?

悬赏问题

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