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

  • Home
  • SEARCH
  • 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 6174483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:45:41+00:00 2026-05-23T23:45:41+00:00

So I have the following code. It’s supposed to send HTML emails that were

  • 0

So I have the following code. It’s supposed to send HTML emails that were edited in the precedent screen. However, once the email is sent, in html tags, the first double quote and letter of each tag go missing, for instance,

<span style="something">

becomes

<span style=omething">

The odd part is, the message is printed fine if echoed to the screen, so I don’t think it has anything to do with how it’s being sent to the whole function, but how it’s being sent to the mail() function…but I have no clue what the issue could be. Here is the code, without all the getting of variables and such because i don’t think it’s particularly relevant.

//start of the headers
$headers = "From: $from_name<$from_email>\n";
$headers .= "Reply-To: <$reply_to>\n"; 
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; 
$headers .= "X-Sender: $from_name<$from_email>\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal
$headers .= "Return-Path: <$from_email>\n"; 
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n"; 
$headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n"; 

$message = "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/html\r\n";  //changed to support html
$message .= "Content-Transfer-Encoding: quoted-printable\n"; 
$message .= "\n"; 
/* note: add HTML by changing the Content-Type to text/html */
////TEST 1 - this is where i attempted to hardcode some code in to see if it would send properly: it wouldn't. printed fine though.
$message .="<font class=\"Apple-style-span\" face=\"'Courier New'\" size=\"5\">\n"; 
$message .= "bbbbb<b>bbbb<i>bbb<u>bbb<font class=\"Apple-style-span\" color=\"#000099\">\n"; 
$message .= "bbbbb<span class=\"Apple-style-span\" style=\"background-color: rgb(102, 255, 204);\">bbbbbb</span></font></u></i></b></font>\n";
/////end test 1
$message .= $body.'\n';
$message .= "\n\n"; 
$message .= "------=MIME_BOUNDRY_message_parts--\n"; 
if($file_present==1){ // added this to fix empty file bug
$message .= "\n"; 
$message .= "------=MIME_BOUNDRY_main_message\n"; 
$message .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n";
$message .= $data; //The base64 encoded message 
$message .= "\n"; 
$message .= "------=MIME_BOUNDRY_main_message--\n"; 
}
echo $message; //this is where it echoes fine, with all tags intact
// send the message
   if( mail("$to_name<$to_email>", $subject, $message, $headers)){ //this is where it goes wrong.
     echo("<p>Message successfully sent to ".$to_email.".</p>");
  } else {
   echo("<p>Message delivery to ".$to_email." failed.</p>");
  }
  • 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-05-23T23:45:42+00:00Added an answer on May 23, 2026 at 11:45 pm

    Well, I’ve been going through my old questions. Figured I should post how I solved this. My initial assumption for this was right: there was nothing wrong with the body of the message. The issue was…

    The headers! No, it doesn’t really make sense to me. But after I initially removed the X-Sender/related header information, everything started sending almost fine. Then I changed the boundary to a random value, and suddenly everything worked fine. Anyone who can explain to me why this happens is welcome to, but I’m just glad it works.

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

Sidebar

Related Questions

I have following code in html: <div> <div style=float:left;margin:0.5em> <span class=title>Label1</span><br/> <input type=text name=name1
I have following code that is accepting a form submission [ActionName(TestingTemp), AcceptVerbs(HttpVerbs.Post)] public ActionResult
I have following code in a python script try: # send the query request
I have following code. Damn, I stuck with this, I know that is very
I have following code in my MVC2 view: <tr class=edit style=display:none> <td> <%= Html.DropDownList(drpFields,
I have following code in my MVC2 view: <tr class=edit style=display:none> <td> <%= Html.DropDownList(drpFields,
I have following code: $boxId = 1; $explainationBox='<input type=button id=<?php echo $boxId; ?> value=send
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I'm trying to use opengl in C#. I have following code which fails with

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.