PHP mail()using html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bond0bhave
Forum Newbie
Posts: 5
Joined: Wed May 29, 2002 1:55 am
Location: Durban, South Africa

PHP mail()using html

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
bond0bhave
Forum Newbie
Posts: 5
Joined: Wed May 29, 2002 1:55 am
Location: Durban, South Africa

Post by bond0bhave »

You BEAUTY!!!!!!!!

thank you

it works, YAY
Post Reply