StefanRSA Posted October 21, 2009 Share Posted October 21, 2009 I am sending mail from a form using smtp authentication. When I use HTML in my message, It ignores my HTML tags and print them out in the email.... My Mail script works as follow: include("Mail.php"); /* mail setup recipients, subject etc */ $headers["From"] = "[email protected]"; $headers["To"] = $frmail; $headers["Subject"] = "The mail subject"; $headers["Reply-To"] = $replyemail; $mailmsg = "Message for mail goes here. \n <a href='http://www.domain.com'>CLICK HERE</a> \n Greetings from Domain"; /* SMTP server name, port, user/passwd */ $smtpinfo["host"] = "mail.domain.com"; $smtpinfo["port"] = "25"; $smtpinfo["auth"] = true; $smtpinfo["username"] = "user+domain.com"; $smtpinfo["password"] = "password"; /* Create the mail object using the Mail::factory method */ $mail_object =& Mail::factory("smtp", $smtpinfo); /* Ok send mail */ $mail_object->send($frmail, $headers, $mailmsg); What must I add to accept HTML in my sent mail? Link to comment https://forums.phpfreaks.com/topic/178463-send-smtp-mail-with-html/ Share on other sites More sharing options...
ILMV Posted October 21, 2009 Share Posted October 21, 2009 Yes, you need to add this to your headers $headers 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; I don't know how you would fit it in with your script, cannot be that difficult Link to comment https://forums.phpfreaks.com/topic/178463-send-smtp-mail-with-html/#findComment-941124 Share on other sites More sharing options...
StefanRSA Posted October 21, 2009 Author Share Posted October 21, 2009 Have tried it... It breaks my code and the mail don't get send... If anybody can tell me how I should add this to my script? Link to comment https://forums.phpfreaks.com/topic/178463-send-smtp-mail-with-html/#findComment-941131 Share on other sites More sharing options...
chronister Posted October 21, 2009 Share Posted October 21, 2009 Get PHPMailer class. You can search Google and find it. It is SOOOO easy to use. It can use mail(), SMTP, Gmail ..... very nice class Link to comment https://forums.phpfreaks.com/topic/178463-send-smtp-mail-with-html/#findComment-941141 Share on other sites More sharing options...
StefanRSA Posted October 21, 2009 Author Share Posted October 21, 2009 If I use mail() some mail clients mark it as spam... This is the reason for sending with smtp. My script is working and I don't want to change it to a diff class. I want to know what I should do to allow for HTML in emails sent using SMTP..... Or do I miss anything? Link to comment https://forums.phpfreaks.com/topic/178463-send-smtp-mail-with-html/#findComment-941144 Share on other sites More sharing options...
StefanRSA Posted October 21, 2009 Author Share Posted October 21, 2009 Anybody? Link to comment https://forums.phpfreaks.com/topic/178463-send-smtp-mail-with-html/#findComment-941232 Share on other sites More sharing options...
chronister Posted October 21, 2009 Share Posted October 21, 2009 The reason I said use PHPMailer, is because it is so flexible it takes care of all the MIME Boundry strings and allows you to send text only, HTML only text/html emails and there are a lot of other nice features with it. This is what needs to go to make it HTML viewable. But the way your passing in the $headers information will make it a little different. $headers 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; do you have to pass the header information in as array items? You need to determine how to add the mime version and content type to the headers. Those are the key pieces. there is also a mailer type declaration, that I cannot remember off hand how it is setup, but you can google for it. Or you can make a few changes and go with PHPMailer class and be done with it. I fought and fought with emails before I found PHPmailer. Once I figured out how to use it, I have not had mail hit the spam folder, sent HTML mail with a text-only version .... easy peasy Link to comment https://forums.phpfreaks.com/topic/178463-send-smtp-mail-with-html/#findComment-941264 Share on other sites More sharing options...
StefanRSA Posted October 21, 2009 Author Share Posted October 21, 2009 Thanks Chronister, I will look into your solution. This might be my only answer. Link to comment https://forums.phpfreaks.com/topic/178463-send-smtp-mail-with-html/#findComment-941274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.