Page 1 of 1

php sendmail html messages get garbled.

Posted: Wed Jun 15, 2011 4:52 pm
by cjkeane
Hi everyone:

i'm using php sendmail to send an email to respond to messages stored in a db. if incoming messages are stored as text, the reply message sends without any issues. if the email saved in the db is html, the reply email gets a bit garblemed eg it includes

several lines of code beginning with /* Font definitions */ and ending with xml.

is there any way to prevent that garbled text from displaying in the message?

or any ideas why it occurs?

Re: php sendmail html messages get garbled.

Posted: Thu Jun 16, 2011 12:17 pm
by twinedev
If you are doing anything over just basic text, I recommend using the phpmailer class (http://phpmailer.worxware.com/)

Here is direct link to the page to download for PHP 5:
http://sourceforge.net/projects/phpmail ... er%20v5.1/

The main file that you need to upload to your server to use this is the class.phpmailer.php file

See the file test_sendmail_advanced.php in the examples folder for a sample of sending an HTML email. The only thing you may also need that isn't in this example is the AddCC() and AddBCC() which are used similar to AddAddress() (note, all three of these can be called multiple times to include more that one for each)

This is a great little script, been using it for years.

-Greg