Deoctor Posted March 1, 2010 Share Posted March 1, 2010 Hai i have made one email program with the html content but still i get the html code in my mail can any one help me out.. <!-- send mail using an smtp--> <?php require_once "Mail.php"; $from = ""; $to = ""; $subject = "Hi!"; $body = "<h1>Hi</h1>,\n\nHow are you?"; $body .= ' <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> '; $host = ""; $username = ""; $password = ""; /*$host = "mail.example.com"; $username = "smtp_username"; $password = "smtp_password";*/ $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/ Share on other sites More sharing options...
trq Posted March 1, 2010 Share Posted March 1, 2010 Ive not used any of the pear libs but It would seem you'll want to use Mail_mime to send html emails. Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/#findComment-1019796 Share on other sites More sharing options...
Deoctor Posted March 1, 2010 Author Share Posted March 1, 2010 i already have the mime version install in the pear.. but it is not working when i try sending mail from my local machine but when i sent that from my server it is sending the mail correctly. Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/#findComment-1019799 Share on other sites More sharing options...
inversesoft123 Posted March 1, 2010 Share Posted March 1, 2010 http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/#findComment-1019806 Share on other sites More sharing options...
Deoctor Posted March 1, 2010 Author Share Posted March 1, 2010 This one i saw it before, but it is not working though.. Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/#findComment-1019807 Share on other sites More sharing options...
Spikerok Posted March 1, 2010 Share Posted March 1, 2010 You can try using ob_start() and in some mail boxes html is disabled by default. So in some thing like SquirrelMail html might be disabled when in hotmail it will be enabled. Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/#findComment-1019810 Share on other sites More sharing options...
Deoctor Posted March 1, 2010 Author Share Posted March 1, 2010 You can try using ob_start() and in some mail boxes html is disabled by default. So in some thing like SquirrelMail html might be disabled when in hotmail it will be enabled. i am sending the mail to my gmail id using my smtp server.. when i send it using the localhost it does not sent in the html format where as if i send using my server it sends.. but i want the mail to be sent using my local host so hw do i do it..?? Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/#findComment-1019812 Share on other sites More sharing options...
sangoku Posted March 1, 2010 Share Posted March 1, 2010 i am not expert in sending mails over pear but where did you tell it that it is a html/text type mail, you have to specify that in the body content.... don't know how to do it with pear tough i suggest not to use it, from the bottom of my heart Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/#findComment-1019826 Share on other sites More sharing options...
Deoctor Posted March 2, 2010 Author Share Posted March 2, 2010 hi sangoku i dont know whether u have checked the code properly but here is where i am mentioning to content type $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/193755-html-mail-issue/#findComment-1020242 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.