Re: mail() problem

From: Manuel Lemos (mlemos_at_acm.org)
Date: 01/19/05


Date: Wed, 19 Jan 2005 00:28:53 -0200

on 01/18/2005 09:33 PM Matt said the following:
>>on 01/06/2005 11:54 PM Matt said the following:
>>>I'm constructing html emails using a php script. I created a program
>>>that creates the html code perfectly and displays it to the screen as a
>>>preview. one part of the program takes the output of the preview and puts
>>>it into a file to zip it. This portion works fine. The variable has all
>>>the html code and the zipped file unzips to the correct html file. I
>>>then created a program to email this html code as the body of an email.
>>>This is where I had a problem. I was using phpmailer and it worked fine
>>>the first time. during another try w/ different information in the html
>>>code (but same html code) there were added and removed characters, and
>>>most notably, an &#10 and &#13, which I believe is a CR/LF. there are
>>>some added ! throughout the code and a few removed letters. they do NOT
>>>correspond to variables that go into the html. they are in the middle of
>>>the hard coded section. I tested the variable by displaying the body
>>>variable after emailing it and it works fine. I tried the same process
>>>using mail() instead of phpmailer, and I got the same results. I sent
>>>the email to another account and instead of &#10 and &#13 the code
>>>started on the next line. either way this does not view correctly in an
>>>email client! does anyone have any suggestions??
>>You should not send HTML only messages because most spam filters will
>>discard your messages for not looking like real messages sent by human
>>users. Human users use normal mail programs that can send HTML messages
>>but also include an alternative text part.
>>
>>Anyway, your problem seems to be due to incorrect encoding. Plain text or
>>HTML messages should be encoded with quoted-printable encoding. That
>>encoding avoids all the problems you mentioned.
>>
>>If you do not know how to encode with quoted-printable encoding, you may
>>want to try this popular MIME message composing and sending class that not
>>only supports quoted-printable encoding but also can compose HTML messages
>>with alternative text parts. Take a look in particular to the example
>>script test_html_mail_message.php .
>>
>>http://www.phpclasses.org/mimemessage
>
> Thanks for the reply. I've been playing with it some more. First off, i
> wordwrapped the body at 72 characters. That fixed MOST of the problems, but
> now i get a space removed from the HTML code. I now encode the body in
> base64, but i think that's different than using quoted-printable encoding.
> Should i encode it in php or just put it in the header so the mail program
> reads it better?

Most modern spam filters discard text/plain or text/html message encoded
as base64. That is because real mail client programs never use base64
except for binaries. So base64 encoding is a pattern of messages used by
  spammers to make it more difficult to look inside messages.

quoted-printable encoding already takes care of breaking the lines of
the encoded text without altering the contents of the decoded text.

I suggest that you follow the standards and do not bother to re-invent
the wheel. Using existing components for generating and sending e-mail
correctly composed will save you countless hours of trying to figure how
to send messages without the inconvinients that are you facing and
others that you are still not aware.

-- 
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html


Relevant Pages

  • Re: [PHP] HTML Email Composing Problem.
    ... MIME_BASE64_TEXT RAW: ... messages are spammers. ... To get rid of the last one, don't base_64 encode your html content. ...
    (php.general)
  • Re: [PHP] HTML Email Composing Problem.
    ... MIME_BASE64_TEXT RAW: ... future reference so any thoughts would be great. ... Your message contains html. ...
    (php.general)
  • Re: Where to get BeautifulSoup--www.crummy.com appears to be down.
    ... Beautiful Soup uploaded to my website: ... obtaining a sensible parse tree in the face of common HTML errors. ... the encoding of an HTML or XML document, ... appears after this Tag in the document.""" ...
    (comp.lang.python)
  • Re: How do we get there from here?
    ... > then sub the whole of that generated markup into the template? ... layed out on the fly, a simple IMG tag, or even an entire HTML document. ... PHP scripting provides 10 times the features of both of these ... idea as tokens can eliminate a huge amount of maintance, ...
    (comp.databases.pick)
  • Re: query string passing woes........ help... please....
    ... |> | offer any help other than saying that my validation could be FAR more ... I'm a total newbie at php. ... The easiest way for you would be to make the html form called form.php ... $_SESSION array using the same names. ...
    (alt.php)