You are here: Re: PHP Sending HTML Formatted Emails « PHP Programming Language « IT news, forums, messages
Re: PHP Sending HTML Formatted Emails

Posted by Manuel Lemos on 03/19/07 03:36

Hello,

on 03/18/2007 11:24 PM robbiesmith79@gmail.com said the following:
> Just so this is out there on the web, I battled the past 24 hours
> about this. Background info... I developed a ecommerce website in PHP
> 4 on a shared linux hosting plan from GoDaddy and had the html
> formatted emails sending as text/html and were going fine with limited
> header information. Then we moved the site over to a Dedicated Linux
> hosting plan. This time, it's PHP 5. Things are bound to not work as
> expected moving to a new programming language.
>
> So what worked in PHP 4:
>
> $headers = 'MIME-Version: 1.0' . "\r\n";
> $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
>
> Now needs to be (at least what worked for me) in PHP 5
>
> $headers = "MIME-Version: 1.0\n";
> $headers .= "Content-type: text/html; charset=iso-8859-1\n";
> $headers .= "X-Priority: 3\n";
> $headers .= "X-MSMail-Priority: Normal\n";
> $headers .= "X-Mailer: php\n";
>
> For the life of me I could not figure out why text/html formatted
> emails were always sending as plain text and all the information was
> shown in the body text using the PHP 4 method.
>
> There... I hope I have saved someone else the trouble of losing the
> amount of hair I did over this.

I think the problem has nothing to do with the version but rather with
the MTA that used in the servers you tried. Depending on the MTA, the
line breaks may be processed differently.

Anyway, sending HTML messages like that you will have also message
filtering problems. You cannot send messages with text/html has main
content-type. That is not the way common mail programs will send HTML
formatted messages. Many systems will discard messages composed like
that because it is a sympthom that you are using a bulk mailing script
that may be spam.

What you need to do is to compose a multipart/alternative message that
encloses a text/plain part and an text/html part. If you do not know how
to do that, you can try many of the ready to use classes that can
compose multipart/alternative messages. I use this MIME message class:

http://www.phpclasses.org/mimemessage


--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация