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 7158853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:08:06+00:00 2026-05-28T13:08:06+00:00

Ok, I’ve asked this question before but I didn’t get a clear answer and

  • 0

Ok, I’ve asked this question before but I didn’t get a clear answer and this time I will also explain it better.

I’ve got an contact form that when submitted, the submission email received is in plain text which is NOT what I want. I want the submission to have at least some style and to be neater (using my own HTML below). I’ve tried to get this to work before but with no success, and now need outside assistance.

Here’s the process php form:

 <?php if (!isset($_SESSION)) session_start();

 if(!$_POST) exit;

if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");


$address = "email@domain.com";
$bcc = "email@domain.com";

    $twitter_active     = 0;
    $twitter_user       = ""; 
    $consumer_key       = "";
    $consumer_secret    = "";
    $token              = "";
    $secret             = "";


$name    = $_POST['name'];
$email  = $_POST['email'];
$phone  = $_POST['phone'];
$dayin  = $_POST['dayin'];
$dayout = $_POST['dayout'];
$comments = $_POST['comments'];

if (isset($_POST['verify'])) :
    $posted_verify   = $_POST['verify'];
    $posted_verify   = md5($posted_verify);
else :
    $posted_verify = '';
endif;

// Important Variables
$session_verify = $_SESSION['verify'];

if (empty($session_verify)) $session_verify = $_COOKIE['verify'];

$error = '';

    if(trim($name) == '') {
        $error .= '<li>Your name is required.</li>';
    }

    if(trim($email) == '') {
        $error .= '<li>Your e-mail address is required.</li>';
    } elseif(!isEmail($email)) {
        $error .= '<li>You have entered an invalid e-mail address.</li>';
    }

    if(trim($phone) == '') {
        $error .= '<li>Your phone number is required.</li>';
    } elseif(!is_numeric($phone)) {
        $error .= '<li>Your phone number can only contain digits (no 
spaces).</li>';
    }

    if(trim($comments) == '') {
        $error .= '<li>You must enter a message to send.</li>';
    }

    if($session_verify != $posted_verify) {
        $error .= '<li>The verification code you entered is incorrect.
</li>';
    }

    if($error != '') {
        echo '<div class="error_message">Attention! Please correct the 
errors below and try again.';
        echo '<ul class="error_messages">' . $error . '</ul>';
        echo '</div>';

    } else {

    if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); }

     $e_subject = 'Website Enquiry';

     $msg = '<html><body>
     <strong>WEBSITE ENQUIRY FROM:</strong><br>
     www.domainname.com<br>
     -----------------------------------------------------------<br><br>
     <strong>Name: </strong>
     '.$_POST['name'].' <br>
     <strong>Email: </strong>
     '.$_POST['email'].' <br>
     <strong>Contact Number: </strong>
     '.$_POST['phone'].' <br>
     <strong>Day in: </strong>
     '.$_POST['dayin'].' <br>
     <strong>Day out: </strong>
     '.$_POST['dayout'].'<br><br>
     <strong>Notes / Comments: </strong><br>
     '.$_POST['comments'].'
     </body></html>';

    if($twitter_active == 1) {

        $twitter_msg = $name . " - " . $comments . ". You can contact " . 
$name . " via email, " . $email ." or via phone " . $phone . ".";
        twittermessage($twitter_user, $twitter_msg, $consumer_key, 
$consumer_secret, $token, $secret);

    }

    $msg = wordwrap( $msg, 70 );

    $headers = "From: $email\r\nBCC:{$bcc}\r\n" . PHP_EOL;
    $headers .= "Reply-To: $email" . PHP_EOL;
    $headers .= "MIME-Version: 1.0" . PHP_EOL;
    $headers .= "Content-type: text/html; charset=utf-8" . PHP_EOL;
    $headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;

    if(mail($address, $e_subject, $msg, $headers)) {

     echo "<fieldset>";
     echo "<div id='success_page'>";
     echo "<img src='success.png' align='absmiddle' style='padding-right:5px;' 
/><strong>Email Sent Successfully.</strong>";
     echo "</div>";
     echo "</fieldset>";

     } else {

     echo 'ERROR!'; // Dont Edit.

     }

}


function twittermessage($user, $message, $consumer_key, $consumer_secret, $token, 
$secret) { // Twitter Direct Message function, do not edit.

require_once('twitter/EpiCurl.php');
require_once('twitter/EpiOAuth.php');
require_once('twitter/EpiTwitter.php');

$Twitter = new EpiTwitter($consumer_key, $consumer_secret);
$Twitter->setToken($token, $secret);

$direct_message = $Twitter->post_direct_messagesNew( array('user' => $user, 'text' 
    => $message) );
$tweet_info = $direct_message->responseText;

 }
?>

Take note of this code in the form above:

 $msg = '<html><body>
     <strong>WEBSITE ENQUIRY FROM:</strong><br>
     www.domainname.com<br>
     -----------------------------------------------------------<br><br>
     <strong>Name: </strong>
     '.$_POST['name'].' <br>
     <strong>Email: </strong>
     '.$_POST['email'].' <br>
     <strong>Contact Number: </strong>
     '.$_POST['phone'].' <br>
     <strong>Day in: </strong>
     '.$_POST['dayin'].' <br>
     <strong>Day out: </strong>
     '.$_POST['dayout'].'<br><br>
     <strong>Notes / Comments: </strong><br>
     '.$_POST['comments'].'
     </body></html>';

I would like to replace this code above (which produces a plain text email) with this STYLED HTML:

<table width="550" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="78" colspan="2" align="center" valign="middle" bgcolor="#F0F5FB"><span 
style="font-family:Georgia, 'Times New Roman', Times, serif; font-size: 24px; 
font-style:italic; color:#0099CC; ">WEBSITE ENQUIRY FROM:</span><br />
  <span style="font-family:Arial, Helvetica, sans-serif; font-size:12px;  
color:#333333">www.domainname.com</span></td>
</tr>
<tr>
<td width="177" height="166" valign="middle"><span style="font-family:Arial, 
Helvetica, sans-serif; font-size:14px; color:#333333; font-weight:bold;">Name:<br />
Country<br />
Contact Number<br />
Email<br />
No. Guests<br />
Day in<br />
Day Out<br />
Comments
</span></td>
<td width="373" valign="middle"><span style="font-family:Arial, Helvetica, sans-serif; 
font-size:14px; color:#333333; font-weight:bold;">'.$_POST['name'].'<br />
'.$_POST['country'].'<br />
'.$_POST['tel'].'<br />
'.$_POST['email'].'<br />
'.$_POST['guests'].'<br />
'.$_POST['day in'].'<br />
'.$_POST['day out'].'<br />
'.$_POST['comments'].'<br />


</span></td>
</tr>
</table>

On a step by step basis, what do need to do to get this to work. I’ve tried replacing the plain text code with my STYLED html and it doesn’t work. What else do I need to do?

Appreciate your responses!

EDIT

Please check here:
Here’s what the HTML email should look like: http://www.testing123.co.za/styled.jpg ….. Here’s how it turns out instead: http://www.testing123.co.za/not-correct.jpg

  • 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-28T13:08:06+00:00Added an answer on May 28, 2026 at 1:08 pm

    Our (working) code:

    $text = "";
    $text .= "<html>\n";
    $text .= "<body style=\"font-family:Arial; \">\n";
    $text .= "<b>more text</b>";
    . . .
    $text .= "</body>\n";
    $text .= "</html>\n";
    
    $headers = 'From: ' . $frm . "\r\n";
    $headers .= 'To: ' . $mmail_to . "\r\n";
    $headers .= 'Bcc: ' . $mmail_bcc . "\r\n";  
    $headers .= 'Return-Path: ' . $frm . "\r\n";
    $headers .= 'MIME-Version: 1.0' ."\r\n";
    $headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' . "\r\n";
    $headers .= 'Content-Transfer-Encoding: 8bit'. "\n\r\n";
    $headers .= $text . "\r\n";
    
    if (!mail('', $strSubject, '', $headers)) {
    . . . 
    

    maybe you need to add the ‘Content-Transfer-Encoding’
    or maybe the $msg should be part of the $headers ???

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including 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.