Opally has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting "500 Line too long" errors from our own local MS Exchange mail server for our MIME::Lite prepped email from web forms.

I tried adding Encoding => 'quoted-printable' to my MIME::Lite->new statement, but it is illegal to use quoted-printable with multipart/alternative. I was so happy to get multipart/alternative working! But it's pooping out on my long forms.

Ideas about why the HTML code for the email is all strung out in one line, and how to prevent that in the HTML code itself?

Or, is there a different way I should handle my mail preparation from my forms? (something other than MIME:Lite? Easy is good for me, I'm a real n00b.) I REALLY want to use multipart/alternative!

I've talked to our local mail server admins, and they feel that 1000 char lines should be sufficient, I don't blame them.

---Opally

Replies are listed 'Best First'.
Re: Encoding for MIME::Lite?
by clinton (Priest) on Aug 23, 2007 at 18:45 UTC
    From the MIME::Lite docs about Encoding:
    base64 Like "uuencode", but very well-defined. This is how you should send essentially binary information (tar files, GIFs, JPEGs, etc.).

    Have a read of the section in the docs called A MIME PRIMER

    Clint

      here's some more information... my apologies for the multiple replies, I don't see them when I refresh the site...

      I have been reading the docs on MIME::Lite. Encoding base64 does not work with multipart/alternative. I also tried using MIME::Base64 but that seemed to confound the output even more.

      At least I'm getting the output now in HTML format using MIME::QuotedPrint, but it has = signs and some HTML markup showing (despite it all being escaped in the original). It looks like this (snipped)

      Thank you for submitting your school profile to the Core Knowledge Fou +n= dation. You submitted the following data on: Thursday, August 23, +2007 at 1= 2:19:33, server time. = asdf<= tr><= /tr>= <= /tr><= /tr><= /tr> How did you find out about CK? please ignore, testing New = or updated profile? New


      here's some of my form script
      use MIME::Lite; use MIME::QuotedPrint; # # this part generates $email_body for plain text and $email_html for +html text # $msg = MIME::Lite->new( To =>$email_to, From =>$email_of_sender, Subject =>$email_subject, Type =>'multipart/alternative', ); $msg->attach(Type => 'text/plain', Data => $email_body ); $msg->attach(Type => 'text/html', Data => encode_qp($email_html) ); $msg->send;
      thanks for your help!
        Here's the problem:
        $msg->attach( Type => 'text/html', Data => encode_qp($email_html) );

        You're encoding twice. MIME::Lite does that for you - there's no need to call encode_qp yourself.

        Clint