Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Reading e-mail attachment from a webmail

by vgy (Initiate)
on Sep 27, 2007 at 10:27 UTC ( #641320=perlquestion: print w/replies, xml ) Need Help??

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

I'll try to explain my trouble.
I have to read the mail with a browser.
These mail are only mail error return:
"Delivery Status Notification (Failure)"
"Mail Delivery System -->Undelivered Mail Returned to Sender"
and any kind of error return.
All of these mails contains 2 attachment file.
the first file is
"Reporting-MTA: dns;
X-Mail-Service-Queue-ID: 52C1DB98D9
X-Mail-Service-Sender: rfc822; xxxx@yyyy.zz
Arrival-Date: Wed, 26 Sep 2007 08:43:24 +0200 (CEST)

Final-Recipient: rfc822; XXX@YYYY.ZZ
Original-Recipient: rfc822;XXX@YYYY.ZZ
Action: failed
Status: 5.7.1
Remote-MTA: dns; mx.xxxx.yy
Diagnostic-Code: smtp; 550 5.7.1 Unable to relay for XXXX@YYYY.ZZ
the second contains the original message.
I need to read these file for parsing and extract information from. What module can I use?
Any suggestion are welcome
  • Comment on Reading e-mail attachment from a webmail

Replies are listed 'Best First'.
Re: Reading e-mail attachment from a webmail
by almut (Canon) on Sep 27, 2007 at 10:56 UTC

    The exact procedure probably depends a lot on the webmail service provider and/or webmail software... Most of them require you to go through several hoops (i.e. pages, dialog boxes, etc.) to download the attachment. WWW::Mechanize would probably be a good start to automatize the steps.

    But before going into that, have you made sure that you really can't access the mail in any other way, e.g. POP3 or IMAP?

Re: Reading e-mail attachment from a webmail
by rdfield (Priest) on Sep 27, 2007 at 10:58 UTC
    It depends on what access you have: I use Net::POP3 quite successfully to process mail programmatically. If the mailboxes aren't fronted by a POP3 server, it would be of no use, though.


      I use the POP3
      I have seen the Net::POP3 module
      but can't extract the attachment file
        I use the POP3
        I have seen the Net::POP3 module

        It's always a good idea to include important details right from the start... :)

        but can't extract the attachment file

        Same here. What exactly is the problem? Is the attachment missing entirely? Are you unable to decode its transfer encoding (e.g. base64), etc.? Could you provide some complete (but short) raw example message, and possibly also some actual code, so we have an idea of what you've tried so far, and where you're stuck?

Re: Reading e-mail attachment from a webmail
by jethro (Monsignor) on Sep 28, 2007 at 00:42 UTC
    WWW:Mechanize is probably what you want. But if that doesn't work then you should think about forwarding these emails to somewhere were you have file or pop access

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://641320]
Approved by naikonta
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2023-06-02 04:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found