Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: MIME::Parser parse_data

by boosth (Initiate)
on Jan 17, 2013 at 20:42 UTC ( #1013887=note: print w/ replies, xml ) Need Help??


in reply to Re^3: MIME::Parser parse_data
in thread MIME::Parser parse_data

The issue appears to be that this call:

my $tmpMessage = $parser->parse_data($body);
Is returning decoded strings for some emails but not for others. Some of the emails require the output of this call:
$tmp_part->bodyhandle->as_string;
to be decoded manually and others do not. I don't understand why sometimes this call
$tmp_part->bodyhandle->as_string;
Returns a human readable decoded string on some emails with base64 encoding but not on all emails with base64 encoding. This is a headache for me because if I change the code to just output the string it breaks on emails that need the string manually decoded. All I am doing is calling "parse_data" and then "bodyhandle->as_string". I'm not sure where the decoding process happens. The original data is definitely base64 encoded which I can see by looking at the raw email data.


Comment on Re^4: MIME::Parser parse_data
Select or Download Code
Re^5: MIME::Parser parse_data
by boosth (Initiate) on Jan 17, 2013 at 23:15 UTC
    For reference sake I used this method:
    if($tmp_part->bodyhandle->as_string =~ m/^(?: [A-Za-z0-9+\/]{4} ) * (? +:[A-Za-z0-9+\/]{2} [AEIMQUYcgkosw048] = | [A-Za-z0-9+\/] [AQgw] ==)?\ +z/x) { $MessageBody = + " - ". decode('UTF-8',decode_base64($tmp_part->bodyhandle->as_strin +g)); } else { $MessageBody = + " - ". $tmp_part->bodyhandle->as_string; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013887]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2014-08-22 11:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (155 votes), past polls