Jalo Creer
Jalo Creer

Reputation: 23

PHPMAILER, IsHTML already set to true

The isHTML is already set to True. But it doesnt work in the email i receive. I just get the sample html from a tutorial.

  <?php
    require("phpmailertest/class.phpmailer.php");
    $x=$_SESSION['items'];
        $mail = new PHPMailer();
        $mail->IsSMTP(); // set mailer to use SMTP
        // $mail->SMTPDebug  = 2; 
        $mail->From = "[email protected]";
        $mail->FromName = "BravoTech Solutions";
        $mail->Host = "smtp.gmail.com"; // specif smtp server
        $mail->SMTPSecure= "ssl"; // Used instead of TLS when only POP mail is selected
        $mail->Port = 465; // Used instead of 587 when only POP mail is selected
        $mail->SMTPAuth = true;
        $mail->Username = "[email protected]"; // SMTP username
        $mail->Password = "Ichthys030313!"; // SMTP password
        $mail->AddAddress($_SESSION['email_address']);
        $mail->IsHTML(true); 

        $mail->Subject  = "Mail Test";

        $mail->Body = '<html><body>';
        $mail->Body = '<table style="border-color: #eee;"';
        $mail->Body = '<tr>
                            <td>JALOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
                            <td>OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
                        <tr>
                            <td>BENEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEDICT
                            <td>PAYOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOT
                    </table>';

        $mail->WordWrap = 50;

        if(!$mail->Send()) {

        echo 'Message was not sent.';
            session_destroy();
        echo 'Mailer error: ' . $mail->ErrorInfo;

        } else {

        echo 'Message has been sent.';

        }
    ?>

Upvotes: 0

Views: 1629

Answers (2)

Synchro
Synchro

Reputation: 37818

You can set Body (and AltBody) manually to any value you like. msgHTML() is a convenience function to set moth of them and optionally apply an html to text conversion to generate your plain text version. It also sets isHTML, rewrites image URLs and various other things - but you don't have to use it.

In your code you're saying:

$mail->Body = '<html><body>';
$mail->Body = '<table style="border-color: #eee;"';
$mail->Body = '<tr>...

Which should be:

$mail->Body = '<html><body>';
$mail->Body .= '<table style="border-color: #eee;"';
$mail->Body .= '<tr>...

otherwise you're just overwriting the contents of Body each time.

You should base your code on the gmail example bundled with PHPMailer - it looks like you are using an old one from somewhere else.

Upvotes: 1

violator667
violator667

Reputation: 499

I'm not sure (correct me if I'm wrong) but I was always setting body like this:

$mail->MsgHTML($body);

Upvotes: 0

Related Questions