Page 1 of 1

PHP mail()using html

Posted: Wed May 29, 2002 1:55 am
by bond0bhave
Hi

I wanted help with the php mail().

I am working on a little helpdesk program, and I want it to send to the users when submit requests, and notifications, but I cant pass html into the mail(), and I wanted to know what the correct way of doing this is.

Thanks

Here is the code

mail("".$worker_email_address."", "job#".$jobno."", $msg_worker,"From: $email\r\n"); }

$worker_email_address= the persons email
$jobno = the number of the job
$msg_worker = the message
$email = my email

Thanks

Posted: Wed May 29, 2002 2:04 am
by twigletmac
To send HTML e-mail you need to add extra headers to the message.

Taken directly from the manual (http://www.php.net/manual/en/function.mail.php):

Code: Select all

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

/* additional headers */
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n";
So in your case you would need to have:

Code: Select all

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $email\r\n";
mail($worker_email_address, 'job#'.$jobno, $msg_worker, $headers);
Hope this helps,
Mac

Posted: Wed May 29, 2002 2:09 am
by bond0bhave
You BEAUTY!!!!!!!!

thank you

it works, YAY