Formatting an output for email is quite tricky as some (especially webmail) programs will strip out all or some HTML tags including your doc type ref if included.
I use a custom built function called buildEmail() that accepts a number of parameters such as an array of fields to use in email, the max email width - typically 70 characters and anything else to be included.
When I have created emails in the past I always found difficulty using \n\r to break but soon realised that creating a string using:
PHP Code:
$str = 'text\n\rtext'
will ignore the formatting so you will need to use "" for your string.
You can build up an HTML email and include tables such as:
PHP Code:
$str = "<html>";
$str .= "<body>";
$str .="<table><tr><td>";
$str .= $some_content."</td></tr></table></body></html>";
$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
$to = 'someone@somewhere.net';
$subject = 'Some subject';
mail($to, $subject, $str, $headers);
For more information check out
mail()