9 mail_in
= imaplib
.IMAP4_SSL("imap.gmail.com", 993)
12 typ
, data
= mail_in
.login("shellreef", getpass
.getpass())
13 except imaplib
.error
, e
:
14 print "Login failure: %s" % (e
,)
17 assert typ
== "OK", "imap login returned: %s %s" % (status
, message
)
18 print "Logged in:", typ
, data
20 typ
, num_msgs
= mail_in
.select(mailbox
="Secure")
22 print "imap select failure: %s %s" % (typ
, num_msgs
)
23 print "The 'Secure' tag doesn't exist. Tag some of your EMOTP messages"
24 print "using a new label, named 'Secure'"
28 typ
, all_msgs_string
= mail_in
.search(None, 'ALL')
29 except imaplib
.error
, e
:
30 print "imap search failed: %s" % (e
,)
33 all_msgs
= all_msgs_string
[0].split()
35 typ
, body
= mail_in
.fetch(num
, "(BODY[])")
36 msg
= email
.message_from_string(body
[0][1])
38 body
= str(msg
.get_payload())
39 subject
= msg
.get("Subject")
40 sender
= msg
.get("From")
41 id = msg
.get("Message-ID")
43 #print 'Message %s\n%s\n' % (num, data[0][1])
44 if "--EMOTP_BEGIN--" not in body
:
46 print "%s %s" % (num
, subject
)
49 print otp_decode(body
)
55 o
, i
, e
= popen2
.popen3("./cotp -d")
64 # TODO: support padname
66 o
, i
, e
= popen2
.popen3("./cotp -e")