YORIK’S COFFEE CORNER

You are currently viewing a single post of this guestblog.

Click here to go back the complete page. I would be glad to hear your comments, so don’t hesitate to leave me your feedback below. It will appear on the main guestblog page.


in categories  linux  opensource  permalink:  179   posted on 26.11.2014 20:30
From Yorik
A very simple email checker (works with imap accounts). Run it by setting it in your crontab to run hourly or something.

passwords are bz2-encrypted (not very good security, but better than nothing. Anyway debian machines are highly secured ). Place the string generated by bz2.compress("password") instead of "encryptedpassword" below.

#!/usr/bin/python

import imaplib, pynotify, bz2
check1 = False
check2=False
i1=imaplib.IMAP4_SSL("imap.myserver.net")
i1.login("me@myserver.net",bz2.decompress("encryptedpassword1"))
s1 = i1.status("INBOX","(UNSEEN)")
n1 = s1[1][0].split()[-1].split(")")[0]

i2=imaplib.IMAP4_SSL("imap.gmail.com")
i2.login("me@gmail.com",bz2.decompress("encryptedpassword2"))
s2 = i2.status("INBOX","(UNSEEN)")
n2 = s2[1][0].split()[-1].split(")")[0]

if (n1 != "0") or (n2 != "0"):
    pynotify.init("mail")
    t = "Unread mail"
    m = ""
    if n1 != "0":
        m += n1 + " messages on myserver/n" # change with a backslash
    if n2 != "0":
m += n2 + " messages on gmail/n" # change with a backslash n=pynotify.Notification(t,m) n.show()

First and foremost, your name:

And your message:

To publish it, just press this ...