Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Mailer Class issue :Message body empty

Tags:

php

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       = "[email protected]";
    $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!";
    }
?>
like image 273
Aan Avatar asked May 10 '26 23:05

Aan


1 Answers

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'];

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

like image 82
MatsLindh Avatar answered May 13 '26 12:05

MatsLindh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!