Re: RE: php email question
| From: | DL Neil | Date: | Tue, 26 Feb 2002 13:21:22 +0000 |
| Subject: | Re: RE: php email question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-86237@lists.php.net to get a copy of this message | ||
Terry,
> I am trying to set up a MIME email that would include an HTML and Plain
> Text version of content, such that if the recipient's email client did
> not understand html or have html disabled, that the content would come
> through as plain text, but if html were accepted, the plain text would
> be ignored so that it did not show as duplication.
>
> What I have currently works good for the html but the plain text shows
> up as well. The mail class is from PROFESSIONAL PHP PROGRAMMING.
>
> Snippet of code is:
>
> include("include/plain.inc"); // the plain text version --
>
> returns $body
> include("include/format.inc"); // html version -- returns
> $data
> $subject = "";
> $to = "terry@jumpinteractive.com";
> $from = "adfarm";
> // create an instance
> $mail = new mime_mail;
> $mail->from = $from;
> $mail->to = $to;
> $mail->subject = $subject;
> $mail->body = "";
>
> $content_type="text/html; charset=us-ascii";
> $mail->add_attachment($data, "", $content_type);
>
> $content_type="text/plain";
> $mail->add_attachment($body, "", $content_type);
>
> $mail->send();
> echo("<h2>Newsletter has been sent.</h2>");
It is a good idea to have some content in text even though the main message is in HTML - for those
who have
text-only email clients! However not all clients handle the one-or-the-other scenario. So your
'problem' may be
with the particular client, or may be with the MIME encoding.
Recommend a visit to http://ww.phpguru.org/ and adapt/upgrade
to the MIME and SMTP classes there (download
includes a set of examples - one sounds just like your construction). Have no complaints with my
service/combined HTML and simple-text messages, built on these classes!
Regards,
=dn