Hi,
Can anyone help please..
I am new to PHPMailer. I am using this code to send HTML email but the email I m getting is a plain email with the html synatx included in the email body.
How can I solve this please..
$mail_header["Content-Type"] = "text/html; charset=\"utf-8\"";
$mail_header["From"] = $message_from_email;
// $body = "<html>";
// $body .= "<head>";
// $body .= "<title>" . $message_subject . "</title>";
// $body .= "</head>";
// $body .= "<body>";
$body .= "<br><br>";
$body .= "<b>" . $_POST['txtMessage'] . "</b>";
$body .= "<br><br><br></hr>";
$body .= $_SERVER['REMOTE_ADDR'];
// $body .= "</body>";
// $body .= "</html>";
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->IsSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "mail.jassimrahma.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "noreply@jassimrahma.com";
//Password to use for SMTP authentication
$mail->Password = "xxxxxxxx";
//Set who the message is to be sent from
$mail->SetFrom("noreply@jassimrahma.com", $_POST['txtName']);
//Set an alternative reply-to address
// $mail->AddReplyTo($_POST['txtEmail'], $_POST['txtName']);
//Set who the message is to be sent to
$mail->AddAddress('inbox@jassimrahma.com', 'Jassim Rahma');
//Set the subject line
$mail->Subject = $_POST['txtSubject'];
//Read an HTML message body from an external file, convert referenced images to embedded, convert HTML into a basic plain-text alternative body
$mail->MsgHTML($body);
$mail->IsHTML(true);
//Replace the plain text body with one created manually
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
//Attach an image file
// $mail->AddAttachment('images/phpmailer_mini.gif');
$mail->AddCustomHeader($mail_header);
//Send the message, check for errors
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
Thanks,
Jassim
Xoom Page