View Full Version : PHP FormMail Formatting Output

02-06-2007, 02:36 PM
I have a "Contact" php form using form mail and all is working great. However, the outputed (is that a word?) information on the email is difficult to read. I read somewhere once that one could format the e mail to make it easier to read. What is required to do this?


02-06-2007, 03:52 PM
post ya code

email script please

02-06-2007, 04:23 PM
Page link is www.douglasvalley.net/contact_page.html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Douglas Valley Contact Page</title>
<style type="text/css">
#wrapper {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FFFFFF;
background-color: #911f43;
border: medium solid #FFFFFF;
body {
background-color: #911f43;
a:link {
color: #FFFFFF;
text-decoration: none;
a:visited {
color: #FFFFFF;
text-decoration: none;
a:hover {
color: #911F43;
text-decoration: none;
background-color: #FFFFFF;
.submit {
color: #911F43;
background-color: #FFFFFF;
font-weight: normal;
<script type="text/JavaScript">
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
var a=YY_checkform.arguments,oo=true,v='',s='',err=fal se,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
for (i=1; i<a.length;i=i+4){
if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
if (o.type=='text'||o.type=='password'||o.type=='hidd en'){
if (r&&v.length==0){err=true}
if (v.length>0)
if (t==1){ //fromto
ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
} else if (t==2){
rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
} else if (t==3){ // date
dte=new Date(cy,cm,cd);
if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.g etMonth()!=cm){err=true};
} else if (t==4){ // time
} else if (t==5){ // check this 2
} else if (t==6){ // the same
} else
if (!o.type&&o.length>0&&o[0].type=='radio'){
at = a[i].match(/(.*)\[(\d+)\].*/i);
if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
if (t==2){
if(!oo){s+='* '+a[i+3]+'\n'}
} else if (o.type=='checkbox'){
} else if (o.type=='select-one'||o.type=='select-multiple'){
}else if (o.type=='textarea'){
if (err){s+='* '+a[i+3]+'\n'; err=false}
if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
document.MM_returnValue = (s=='');

<div id="wrapper">
<p align="center"><img src="Images/dv_logo_sm.jpg" alt="Douglas Valley Logo" width="400" height="200" /></p>
<p align="center">Please complete form below and then click on the Send Inquiry button at bottom.&nbsp; We will contact&nbsp; you promptly.</p>
<form action="http://www.douglasvalley.net/contact.php" "method="post" name="Contact Form" id="Contact Form" onsubmit="YY_checkform('Contact Form','first_name','#q','0','Please Complete First Name','Phone_No','#q','0','Please Complete Phone Number','E_Mail','#q','0','Please Complete E Mail Address');return document.MM_returnValue">
<table align="center" cellpadding="5" cellspacing="0" id="Form_Table">
<td>First Name* </td>
<td><input name="first_name" type="text" id="first_name" size="30" /></td>
<td>Last Name* </td>
<td><input name="Last_Name" type="text" id="Last_Name" size="30" /></td>
<td><p>Street Address </p> </td>
<td><input name="Street_Address" type="text" id="Street_Address" size="45" /></td>
<td><input name="City" type="text" id="City" size="30" /></td>
<td><input name="State" type="text" id="State" size="2" maxlength="2" /></td>
<td>Zip Code </td>
<td><input name="Zip_Code" type="text" id="Zip_Code" size="9" maxlength="9" /></td>
<td>Phone Number* </td>
<td><input name="Phone_No" type="text" id="Phone_No" size="14" /></td>
<td><input name="E_Mail" type="text" id="E_Mail" size="30" /></td>
<td>Best Time to Contact </td>
<td><select name="Best_Time" id="Best_Time">
<option>(Please Choose One)</option>
<option>Business Hours 8-5</option>
</select> </td>
<td>Please Enter Information Requested Below </td>
<td valign="top"><div ><font size="-1">* = Required </font></div></td>
<td><textarea name="Inquiry_Data" cols="50" rows="20" id="Inquiry_Data"></textarea></td>
<td><div align="center">
<input name="Submit" type="submit" class="submit" value="Send Inquiry" />
<p><a href="index.html">&nbsp;&nbsp; Click here to quit and return to home page</a> </p>

02-06-2007, 05:28 PM
that was the form

can you post the PHP email script

02-06-2007, 08:50 PM
Sorry, here you go.

//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Results from Web Site Contact form';

// Your email address. This is where the form information will be sent.
$emailadd = 'judyc@douglasvalley.net';

// Where to redirect after form is processed.
$url = 'http://www.douglasvalley.net/thank_you.html';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
foreach ($_POST as $key => $value)
if ($req == '1')
if ($value == '')
{echo "$key is empty";die;}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';

02-06-2007, 09:00 PM
please use this script to send a mail to me at


02-06-2007, 09:11 PM
It's on it's way.


02-06-2007, 09:17 PM
if you were sending the mail as HTML then you would have control over font sizes etc but as this is sent as text then its a client side setting through the mail client

i have attached a screen dump of what the mail looks like to me in outlook

I dont see a problem really

02-06-2007, 09:25 PM
Interesting, when I tested it earlier using Outlook XP (2000), the input data was jammed to the left against the field names. I'll do some more testing (and remove you e mail address from the script) and let you know what I find.
thnx again

02-06-2007, 09:29 PM
feel free to use me

if you send any additional mails that you would like to test visually i will post them in this thread as a screen dumps

02-09-2007, 03:16 PM
What I fould out was the out put was viewed not on Outlook but on the web host's webmail. (Note it's Startlogic using Vdeck). For some reason it pushed the results to the left against the field name. I've since revised the form (using the Coffee Cup Form Builder) and the Vdeck reader the hosting company uses formats everything ok.