tmallen Posted November 1, 2007 Share Posted November 1, 2007 I need to send HTML email using PHP, and the solution needs to be very portable (no need for server installations using PEAR, which as far as I know puts the mime_mail extension out of the question). How can I do this? So, anyone know of portable, fairly easy to use HTML email solutions? Quote Link to comment https://forums.phpfreaks.com/topic/75686-solved-html-email-portable-solution/ Share on other sites More sharing options...
kratsg Posted November 1, 2007 Share Posted November 1, 2007 Have you checked out PHP's mail() function? Quote Link to comment https://forums.phpfreaks.com/topic/75686-solved-html-email-portable-solution/#findComment-382994 Share on other sites More sharing options...
tmallen Posted November 1, 2007 Author Share Posted November 1, 2007 How can I make that send HTML email? I know how to use mail() for text emails. Quote Link to comment https://forums.phpfreaks.com/topic/75686-solved-html-email-portable-solution/#findComment-382997 Share on other sites More sharing options...
kratsg Posted November 1, 2007 Share Posted November 1, 2007 Quoted from PHP.net @ http://us.php.net/function.mail Example 1127. Sending HTML email It is also possible to send HTML email with mail(). <?php // multiple recipients $to = 'aidan@example.com' . ', '; // note the comma $to .= 'wez@example.com'; // subject $subject = 'Birthday Reminders for August'; // message $message = ' <html> <head> <title>Birthday Reminders for August</title> </head> <body> <p>Here are the birthdays upcoming in August!</p> <table> <tr> <th>Person</th><th>Day</th><th>Month</th><th>Year</th> </tr> <tr> <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> </tr> <tr> <td>Sally</td><td>17th</td><td>August</td><td>1973</td> </tr> </table> </body> </html> '; // To send HTML mail, the Content-type header must be set $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 mail($to, $subject, $message, $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75686-solved-html-email-portable-solution/#findComment-383001 Share on other sites More sharing options...
tmallen Posted November 1, 2007 Author Share Posted November 1, 2007 In a way this works but the "Additional Headers" line is no good. Here's what I see in the result email. The code follows. Fake Name From: Sitename Cc: fakemail@email.com Bcc: fakemail2@email.com // Additional headers $headers .= 'Fake Name <myfakemail@email.com>' . "\r\n"; $headers .= 'From: Sitename' . "\r\n"; $headers .= 'Cc: fakemail@email.com' . "\r\n"; $headers .= 'Bcc: fakemail2@email.com' . "\r\n"; Note that I've censored the names and emails for privacy. The additional headers didn't successfully affect the From, To, Cc, or Bcc successfully. The HTML mail does work very well though. Quote Link to comment https://forums.phpfreaks.com/topic/75686-solved-html-email-portable-solution/#findComment-383012 Share on other sites More sharing options...
kratsg Posted November 1, 2007 Share Posted November 1, 2007 it needs to be To: Fake Name O-o Quote Link to comment https://forums.phpfreaks.com/topic/75686-solved-html-email-portable-solution/#findComment-383014 Share on other sites More sharing options...
tmallen Posted November 1, 2007 Author Share Posted November 1, 2007 Oye! Touche. Many thanks! Quote Link to comment https://forums.phpfreaks.com/topic/75686-solved-html-email-portable-solution/#findComment-383016 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.