Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

read mail

by cztmonk (Monk)
on Jun 19, 2012 at 07:51 UTC ( #976975=perlquestion: print w/ replies, xml ) Need Help??
cztmonk has asked for the wisdom of the Perl Monks concerning the following question:

Hit there monks.I use Mail::Sendmail to send a mail. This works fine.Which module shoud I use to read my mail? Browsed CPAN for modules, but not sure which one to use. I am working with Windows 7.

Comment on read mail
Re: read mail
by atcroft (Monsignor) on Jun 19, 2012 at 08:06 UTC

      It does help. With Net::POP3 I succeeded to read an (encrypted) message. Thanks for your advice.

      Is there any example code on how to work with Net::POP3, read the cpan documentation but i am not sure that i understand it all

Re: read mail
by marto (Chancellor) on Jun 19, 2012 at 08:27 UTC

    Depending on what you want to do (if it's more than simply reading a mail) Mail::Box may be of interest. See Mail::Box-Overview for more information.

Re: read mail
by chrestomanci (Priest) on Jun 19, 2012 at 08:35 UTC

    Reading mail is not as easy as sending it. To send mail perl only have to speak smtp which is a fairly simple protocol, so there are many tools for the purpose. Also as email is sent via store an forward, you only need to generate the message and send it on it's first hop, and the onward servers take care of the rest.

    For receiving email it is more tricky because of the store and forward nature of the protocol. As atcroft said, if your mail is being delivered and stored to a POP3, or IMAP mailbox, then there are perl modules on cpan that will retrieve mail from those mailboxes.

    It is also possible that your mail will be on some sort of webmail system like google mail. If that is the case then you will have to write or find code to scrape the website using modules such as HTML::TreeBuilder or WWW::Mechanize::Firefox, though in the case of Google, you can configure your account to be accessible via IMAP.

    Finally it might be possible to receive mail directly over SMTP rather than polling a mailbox using something like Net::SMTP::Server or NetServer::SMTP. This would have the advantage of allowing your script to respond to incoming mails in realtime, but to do that you would need your own domain name where you can control the MX record in the DNS, your script would receive all mail to that domain you would need to manually forward any destined for other users yourself. Also you would need to be very cautions setting up such a server on an internet facing site due to the risk of remote hack attacks.

      "It is also possible that your mail will be on some sort of webmail system like google mail. If that is the case then you will have to write or find code to scrape the website using modules such as HTML::TreeBuilder or WWW::Mechanize::Firefox, though in the case of Google, you can configure your account to be accessible via IMAP."

      Webmail systems such as Gmail prohibit scraping/automating their web interfaces in their terms of use. For access they allow POP3 and SMTP. http://support.google.com/mail/bin/answer.py?hl=en&answer=13287.

Re: read mail
by zentara (Archbishop) on Jun 19, 2012 at 10:05 UTC

      Thank you very much. I was in search for just such an example. I will study it carefully.Thanks again.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2014-09-20 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (159 votes), past polls