Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9010019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:21:01+00:00 2026-06-16T02:21:01+00:00

I am using PHPMailer to send HTML emails. I first set the HTML body

  • 0

I am using PHPMailer to send HTML emails. I first set the HTML body of the email using HTML and PHP variables after first calling ob_start.

Here’s my code:

<?php

ob_start();
?>

..... a bunch of VALID HTML

<?
$body = ob_get_contents();

require_once('class.phpmailer.php');

// Send to Me
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSendmail(); // telling the class to use SendMail transport

try {
    $mail->AddReplyTo('info@example.com', 'Company Name');
    $mail->AddAddress('me@example.com', 'My Name');
    $mail->SetFrom('info@example.com', 'Company Name');
    $mail->Subject  =  "Contact Form Confirmation";
    $mail->AltBody    = "This is a contact form submitted through the main website.";
    $mail->WordWrap   =  50; // set word wrap   
    $mail->Body = $body;
    $mail->IsHTML(true); // send as HTML

    $mail->Send(); // Try to send email

    } catch (phpmailerException $e) {
        echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
        echo $e->getMessage(); //Boring error messages from anything else!
}
// end try

For some reason, this line:

$mail->Body = $body;

causes the email not to send. If I replace it with:

$mail->Body = "This is a test email.";

the email sends perfectly.

If my HTML contained within $body is just a valid HTML page with CSS in the head, and no Javascript or anything, why won’t the email send?

Is there another way to do this? Please help!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:21:02+00:00Added an answer on June 16, 2026 at 2:21 am

    Turns out, for some reason, the emails were not sending if they contained a fax number. Totally strange. I tested my entire markup, and after ONLY removing a 10 digit phone number, the emails finally went through. I’m not a newbie – literally that’s the only text I removed and the emails sent fine.

    HAS ANYONE SEEN THIS BEFORE??

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHPMailer to send email from PHP. My email body contains HTML format
Ok, I'm using PHPMailer to send email. So in the php code I add
I'm using phpmailer to send email. But all of my emails are send with
I wrote some code to send an email from my PHP script using PHPMailer.
I am trying to send an email from PHP using PHPmailer() . I have
Hay I'm using PHPMailer to send some simple emails, however the function SetFrom() doesn't
I'm trying to send mail using phpMailer. It's my code: <?php require_once('phpmailer/class.phpmailer.php'); $mail =
I have send an email using php mailer class. mail was sending successfully but
I'm trying to accomplish the following, I'm sending a HTML email using PHP Mailer
I'm using phpmailer to send emails to addresses stored in the variable $to, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.