Re: Invoke shell script on receiving mail

Cameron Simpson <[email protected]>
Newsgroups gmane.linux.redhat.general
Message-ID <[email protected]>
On 23Aug2012 21:20, raj sourabh <[email protected]> wrote:
| I am trying to make a script that does the following:
| 
| * Checks any new mail on my gmail/yahoo account
| * If any new messages - invoke a script on local system ( script will
| generate a number)
| * respond to the mail with this number
| 
| I have tried many things to achieve this did not succeed. If anyone has
| done anything of this kind, Please share your ideas.

I would be inclined to use IMAP to talk to each mail service (to get at
the message list without fetching the message contents). My language of
choice would be Python, both because I like it and because it has an
IMAP library as standard.

There are a whole bunch of issues you need to sort out though: storing
passwords (at a minimum, store then in a separate file with private
permissions i.e. rw-------) and storing the mailbox state - the list of
messages that were present on your last check. A trivial approach might
be to dump all the IMAP message ids to a file as plain text, one per
line. On the next poll, read that file, reread the IMAP list, count new
items and rewrite the file with the current state. Very simple.

Cheers,
-- 
Cameron Simpson <[email protected]>

I am perfectly capable of cooking myself.       - [email protected]

-- 
redhat-list mailing list
unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.