Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: read mail

by chrestomanci (Priest)
on Jun 19, 2012 at 08:35 UTC ( #976983=note: print w/ replies, xml ) Need Help??


in reply to read mail

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.


Comment on Re: read mail
Re^2: read mail
by marto (Chancellor) on Jun 19, 2012 at 08:55 UTC

    "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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2014-07-26 12:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (176 votes), past polls