[thelist] Sending Tabular data with mail()

Chris Price chris.price at choctaw.co.uk
Thu May 22 10:04:35 CDT 2008

Jeffrey Barke wrote:
> Santilal,
> PHP's mail function sends a plain text email, not an HTML one, so no  
> markup is necessary or will work.
There's nothing stopping you sending html emails using php's mail() 
function but you have to send it multipart.

I set a system up for doing this some years ago and it was rather crude 
but it worked. It looked something like this:

$subject = "myCompany Quotation";
$to = $emailTo[$value];

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; 
$headers .= "\r\nReturn-Path: <enquiries at myDomain.co.uk>\r\n";
$headers .= "From: myCompany<enquiry at myDomain.co.uk>\r\n";
$headers .= "Reply-to: enquiries<enquiries at myDomain.co.uk>";

$message = "This is a multi-part message in MIME format. \r\n";
$message .= "\r\n----knabecnarusni\r\n";
$message .= "Content-Type: text/plain; charset=iso-8859-1 \r\n";
$message .= "Content-Transfer-Encoding: 7bit \r\n\r\n";

$message .= "Quotation from myDomain.co.uk \r\n";
$message .= "For: $emailForename[$value] $emailSurname[$value] \r\n\r\n";
$message .= "Thank you for using myCompany. A summary of your recent 
enquiry and quotation is listed below: \r\n\r\n";


$message .= "\r\n----knabecnarusni\r\n";
$message .= "Content-Type: text/html; charset=iso-8859-1 \r\n";
$message .= "Content-Transfer-Encoding: 7bit \r\n\r\n";
$message .= "<html>\r\n";
$message .= "<body link='#003399' vlink='#003399' alink='#003399'>\r\n";
$message .= "<table cellspacing=0 cellpadding=4 border=0>\r\n";

$message .= "<tr>\r\n";
$message .= "<td><img 
$message .= "<td align=right width='100%'><img 
src='http://www.myDomain.co.uk/email/images/myimage.gif' alt=''></td>\r\n";

$message .= "</td>\r\n";
$message .= "</tr>\r\n";
$message .= "</table>\r\n";
$message .= "</body>\r\n";
$message .= "</html>\r\n";

$message .= "\r\n----knabecnarusni--\r\n";


mail($To, $Subject, $Message, $Headers);


Kind Regards

  Chris Price

chris.price at choctaw.co.uk <mailto:chris.price at choctaw.co.uk>
www.choctaw.co.uk <http://www.choctaw.co.uk>

Tel. 01524 825 245
Mob. 0777 451 4488

Beauty is in the Eye of the Beholder while
Excellence is in the Hand of the Professional


 >> Sent on behalf of Choctaw Media Ltd <<


Choctaw Media Limited is a company registered in
England and Wales with company number 04627649

Registered Office: Lonsdale Partners, Priory Close,
St Mary's Gate, Lancaster LA1 1XB . United Kingdom

More information about the thelist mailing list