View Full Version : styling contact form that is sent to my email account

03-23-2007, 09:34 AM
hi guys,

i ve got a standard form that is sent to my email account and at the mo, it looks pretty plain and boring. as seen below.

Contact Form:

FullName: darren azzopardi

Address1: xxx
Address2: xx
Address3: xxx

Postcode: xx

Email: xxx.

is there a way of presenting this any better such as styling the font or colour? Below is a slice of the php code.

$Body .= "FullName: ";
$Body .= $FullName;
$Body .= "\n";
$Body .= "\n";

$Body .= "Address1: ";
$Body .= $Address1;
$Body .= "\n";
$Body .= "\n";
$Body .= "Address2: ";
$Body .= $Address2;
$Body .= "\n";
$Body .= "\n";
$Body .= "Address3: ";
$Body .= $Address3;
$Body .= "\n";
$Body .= "\n";


03-23-2007, 09:52 AM
you can incorporate HTML for those people who view their mail this way. The trouble is for those people who view their mail text only will see the tags.

taken from http://uk.php.net/function.mail (http://uk.php.net/function.mail)

// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<title>Birthday Reminders for August</title>
<p>Here are the birthdays upcoming in August!</p>

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

03-23-2007, 10:46 AM
Cheers for that, most email packages, hotmail, yahoo and outlook can all render html within email cant they.

So to put a font or colour i would simply write it as if it was html?


03-23-2007, 10:49 AM
yes in the tag

although you can use CSS

03-23-2007, 02:55 PM
Email clients are notorious for buggy CSS support. HTML emails is one of those weird occurrences where tables are best. I don't like, but it's the way it is :-(
So use of <font> and <table> is actually recommended..