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? 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? 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. 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 = '[email protected]' . ', '; // note the comma $to .= '[email protected]'; // 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 <[email protected]>, Kelly <[email protected]>' . "\r\n"; $headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; $headers .= 'Cc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?> 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: [email protected] Bcc: [email protected] // Additional headers $headers .= 'Fake Name <[email protected]>' . "\r\n"; $headers .= 'From: Sitename' . "\r\n"; $headers .= 'Cc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\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. 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 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! 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
Archived
This topic is now archived and is closed to further replies.