Wednesday, September 28, 2022
HomeApkChecking for Mail

Checking for Mail

The Basics in Perl

After that, retrieve the Inbox and step through the list of messages in it. Using the get messages method within the Perl library gives you an array of hashes, with the value of ‘new’ being the read/unread flag. So all you need to do is count the number of messages with an accurate value in that reference, like

The Basics in PHP

PHP, too, provides a simple interface to check for new Mail in Gmail. Again, the libgmailler library handles it perfectly well. But, first, you need to log in.

The Basics in Python

Python’s libgmail provides the simplest method to get a new mail count: There’s a specific function that you can use. So, as usual, you first need to log in and check for errors there.

Building on the Basics

Now that you have seen the basics for retrieving the number of unread messages, you can look at new and exciting ways of displaying that number. You saw desktop applications in Chapter 2, so this section concentrates on the more unusual forms of seeing the number.

New Mail Count in RSS

It’s a fair bet that the majority of the readers of a book like this one will also be heavy users of RSS. The XML-based family of syndication technologies is now viral indeed and presents many opportunities for keeping track of many different types of information. For example, I use the following technique to keep tabs on Gmail accounts that I use on an infrequent basis: checking them manually is too much bother, but a desktop alert is too intrusive.

Start, in the usual way, by loading the core Perl modules. In this case, you will need Mail:: Webmail: Gmail, as ever, and the commonly used XML::RSS module to help produce the RSS feed, and the ubiquitous CGI module to deal with the incoming parameters and the correct serving of the feed. Unfortunately, XML::RSS is a little out of the scope of this book and is nevertheless very simple to understand from its documentation.

New Mail Count to AOL Instant Messenger

As well as an RSS reader, you might also have an AOL Instant Messenger (AIM) application running. This section builds two ways of receiving new mail notifications via AIM. The first is by using a script very similar to that. This one checks for Mail, logs in to AIM, and sends you a message with the number. You need to set the script to run on a schedule, and it keeps you up to date in a relatively painless way.

Summary

So now you have seen how to check for new Mail in three languages and create some exciting applications to repurpose that data. In all, quite simple stuff but a good starting point. In the next chapter, you move on to the next logical stage: reading the Mail.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Browse Category