PDA

View Full Version : How to set email encoding type in MIME::Lite?


Opally
08-23-2007, 07:17 PM
I'm getting "500 Line too long" errors from our own mail server for some MIME::Lite prepped email from forms.

this is the code I see in my mail log:

Content-Disposition: inline
Content-Length: 3201
Content-Transfer-Encoding: binary
Content-Type: text/html

I tried adding
Encoding => 'quoted-printable'to my MIME::Lite->new statement, but it is illegal to use quoted-printable with multipart/alternative.

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? 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

Opally
08-23-2007, 10:48 PM
In case someone else has this problem, this is how I solved it:

I had to move the encoding statement into the attach part, out of the main msg part, like this:


$msg = MIME::Lite->new(
To =>$form_data{'email'},
From =>$email_of_admin,
Subject =>$email_subject,
Type =>'multipart/alternative'
);

$msg->attach(Type => 'text/plain',
Data => $email_body
);

$msg->attach(Type => 'text/html',
Encoding => 'quoted-printable',
Data => $email_html
);
$msg->send;