I created a Perl script to file incoming e-mails in our task management system using Email::MIME.
For the most part it has been working well, but I hit a problem recently where the text attachment was filed instead of the text body of the e-mail. It only occurred from one client and doesn't occur when I try to reproduce it.
if ($parsed->xpath_exists('//plain')) {
@nodes = $parsed->xpath_findnodes('//plain');
$text_part = $nodes[0];
$body=$text_part->body;
}
The e-mail had two text parts, but I can't figure out why it didn't select the first in this case.
Message (without headers and HTML)
--=_mixed 007E16738825776F_=
Content-Type: multipart/alternative; boundary="=_alternative 007E16738
+825776F_="
--=_alternative 007E16738825776F_=
Content-Type: text/plain; charset="US-ASCII"
This was the body text
--=_alternative 007E16738825776F_=--
--=_mixed 007E16738825776F_=
Content-Type: text/plain; name="6014969_S02500.txt"
Content-Disposition: attachment; filename="6014969_S02500.txt"
Content-Transfer-Encoding: quoted-printable
This is a text file attachment
--=_mixed 007E16738825776F_=--
Any ideas would be greatly appreciated. Let me know if you need more code or more of the data.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.