Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPmailer sending HTML CODE

Tags:

php

I am using PHPmailer to send email.

I have also used HTML = True content type

    $mail = new PHPMailer();  $mail->IsSMTP();                    // send via SMTP $mail->Host     = $Host;  $mail->SMTPAuth = true;             // turn on SMTP authentication $mail->Username = $Username;   $mail->Password = $Password;   $mail->From     = $From; $mail->FromName = $FromName;      $mail->AddAddress($To , $ToName);  $mail->WordWrap = 50;               // set word wrap     $mail->Priority = 1;  $mail->IsHTML(true);   $mail->Subject  =  $Subject; $mail->Body     =  $Body; 

Once the email is sent i see the actual HTML code instead of the contents please check below

enter image description here

**Not sure what is the issue **

like image 544
user580950 Avatar asked Jun 21 '12 14:06

user580950


People also ask

Why does PHPMailer go to spam?

usually this happens because the sending server is already marked as spam by somebody. The way i found is go to the gmail account mark the item as 'important' in gmail and 'Add to Safe senders' in Outlook.

Is PHPMailer SMTP?

PHPMailer can use a non-local mail server (SMTP) if you have authentication. Further advantages include: It can print various kinds of error messages in more than 40 languages when it fails to send an email. It has integrated SMTP protocol support and authentication over SSL and TLS.

Does PHPMailer work on localhost?

The PHPMailer library provides the easiest way to send an email from localhost with an SMTP server using PHP. Not only the text email, but you can also send HTML email from localhost in PHP using PHPMailer.

Is PHPMailer secure?

PHPMailer doesn't create/use any SQL itself, nor does it have anything to do with javascript, so it's secure on those fronts.


Video Answer


1 Answers

Calling the isHTML() method after the instance Body property (I mean $mail->Body) has been set solved the problem for me:

$mail->Subject = $Subject; $mail->Body    = $Body; $mail->IsHTML(true);       // <=== call IsHTML() after $mail->Body has been set. 
like image 69
Nabil Kadimi Avatar answered Sep 28 '22 08:09

Nabil Kadimi