Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi gang, CENTOS 7, perl 5.

I'm having problems with MIME::Parser extracting (correctly) attachments but incorrectly naming them. An attachment defined as :

Content-Type: application/vnd.openxmlformats-officedocument.spreadshee +tml.sheet; name="Copy of 1501733944381-20170803 Dataload.xlsx" Content-Description: Copy of 1501733944381-20170803 Dataload.xlsx Content-Disposition: attachment; filename="Copy of 1501733944381-20170803 Dataload.xlsx"; size=23847; creation-date="Mon, 09 Oct 2017 12:39:28 GMT"; modification-date="Mon, 09 Oct 2017 12:38:40 GMT" Content-Transfer-Encoding: base64
... and code defined as...
my $emailfile = basename("$email"); my $tmpdir = "/tmp/$emailfile"; mkdir "$tmpdir"; my $parser = MIME::Parser->new(); $parser->decode_headers(1); $parser->output_dir("$tmpdir"); my $message = $parser->parse_open("$email");
... and variable $email defined as a full path and filename, I get a file created in /tmp/$emailfilename as
Copy of 150173.xls
Two things. The name is wrong and the suffix is wrong. I can live with the suffix being wrong but it does point to possibly the problem being with the content-type being something MIME::Parser doesn't fully recognise. Anyone come across anything like this? Anyone solve it?

In reply to Problem with MIME::Parser and filenames by Laurielounge

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-08-11 00:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found