PHP Mailer类问题:消息正文为空 [英] PHP Mailer Class issue :Message body empty

查看:154
本文介绍了PHP Mailer类问题:消息正文为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用PHPMailer类发送电子邮件时,出现此错误: 邮件错误:邮件正文为空:

When i try to send email using PHPMailer class I get this error : Mailer Error: Message body empty :

<?php

    include("class.phpmailer.php");

    $mail = new PHPMailer();
    $mail->IsSMTP();

    $mail->SMTPAuth   = true;

    $mail->SMTPSecure = "ssl";
    $mail->Host       = "rsb20.rhostbh.com";
    $mail->Port       = 465;
    $mail->Username   = "jobserreker+furrtexlab.com";
    $mail->Password   = "12345678a";

    $mail->From       = "jobserreker@furrtexlab.com";
    $mail->FromName   = "Job Seeker";
    $mail->Subject    = $_GET['subject'];
    $mail->MsgHTML($_GET['msg']);

    $mail->AddAddress($_GET['to'],"name to");
    $mail->IsHTML(false);

    if(!$mail->Send())
    {
      echo "Mailer Error: " . $mail->ErrorInfo;

    }else{

        echo "Message sent!";
    }
?>

推荐答案

正如Gerald Versluis所说,由于将IsHTML()设置为false,因此必须使用-> Body属性设置实际的主体.邮件.

As Gerald Versluis said, since you're setting IsHTML() to false, you'll have to use the ->Body property to set the actual body of the mail.

$mail->Body = $_GET['msg'];

您还应该使用POST而不是GET来提交会导致执行操作的内容.

You should also use POST instead of GET for submitting something which causes an action to be performed.

这篇关于PHP Mailer类问题:消息正文为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆