Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Red Hat Linux (http://www.linux-archive.org/red-hat-linux/)
-   -   Invoke shell script on receiving mail (http://www.linux-archive.org/red-hat-linux/697075-invoke-shell-script-receiving-mail.html)

raj sourabh 08-23-2012 05:20 PM

Invoke shell script on receiving mail
 
Hi All,

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.

Thanks in advance.

Regards
Raj
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

Cameron Simpson 08-23-2012 09:18 PM

Invoke shell script on receiving mail
 
On 23Aug2012 21:20, raj sourabh <rajsourabh1@gmail.com> 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 <cs@zip.com.au>

I am perfectly capable of cooking myself. - snail@lsl.co.uk

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

Jack Craig 08-23-2012 09:31 PM

Invoke shell script on receiving mail
 
On Thu, Aug 23, 2012 at 2:18 PM, Cameron Simpson <cs@zip.com.au> wrote:

> On 23Aug2012 21:20, raj sourabh <rajsourabh1@gmail.com> 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.
>

it might be simpler to auto fwd email to a local filesystem and deal with
mail files directly! :)


>
> Cheers,
> --
> Cameron Simpson <cs@zip.com.au>
>
> I am perfectly capable of cooking myself. - snail@lsl.co.uk
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list


All times are GMT. The time now is 01:34 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.