Subscribe

RSS Feed (xml)

PHP-Email: Sending a Simple HTML Mail (Part 2)

May be you ever get advertise email. They send you a html email. The layout is very nice. There are many tables, coloring font, and soon. Yeah, they use html mail. They just set the body of the email to have HTML in it and add one additional header of Content-type: text/html and have it work. Ok, look the code:

02// Setting a timezone, mail() uses this.
03date_default_timezone_set('America/New_York');
04// recipients
05$to  = "you@miscellaneous4all.com" . ", " ; // note the comma
06$to .= "we@miscellaneous4all.com";
07
08// subject
09$subject = "Test for HTML Format";
10
11// To send HTML mail, you can set the Content-type header.
12$headers  = "MIME-Version: 1.0\r\n";
13$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
14
15// additional headers
16$headers .= "To: You ,
17We miscellaneous4all.com>\r\n";
18$headers .= "From: Me miscellaneous4all.com>\r\n";
19$headers .= "Cc: he@miscellaneous4all.com\r\n";
20$headers .= "Bcc: she@miscellaneous4all.com\r\n";
21
22// Your message here:
23$body = "
24
25
26
27
28
29'red'>Hai
30
31
32";
33
34// Finally, send the email
35mail($to, $subject, $body, $headers);
36?>


0 comments:

Related Posts with Thumbnails