Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IMAPClientProject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gregory.swedeen
IMAPClientProject
Commits
2e708d22
Commit
2e708d22
authored
Apr 09, 2018
by
gregory.swedeen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First commit for project ImapClient
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
ImapClientGregSwedeen.py
ImapClientGregSwedeen.py
+80
-0
No files found.
ImapClientGregSwedeen.py
0 → 100644
View file @
2e708d22
from
imapclient
import
IMAPClient
import
email
from
email.utils
import
parseaddr
server
=
None
USERNAME
=
None
Password
=
None
def
login
():
global
server
global
USERNAME
global
PASSWORD
HOST
=
'elwood.yorkdc.net'
ssl
=
False
USERNAME
=
"gregory.swedeen"
PASSWORD
=
"RS85X7WR"
server
=
IMAPClient
(
HOST
,
use_uid
=
True
,
ssl
=
ssl
)
server
.
login
(
USERNAME
,
PASSWORD
)
def
showInbox
():
global
server
select_info
=
server
.
select_folder
(
'INBOX'
)
print
(
'
%
d messages in INBOX'
%
select_info
[
b
'EXISTS'
])
messages
=
server
.
search
([
'NOT'
,
'DELETED'
])
print
()
print
(
"Inbox: "
)
print
(
"| ID | Subject | Sender | Date |"
)
for
msgid
,
data
in
server
.
fetch
(
messages
,
[
'ENVELOPE'
])
.
items
():
envelope
=
data
[
b
'ENVELOPE'
]
name
=
str
(
envelope
.
sender
)
sender
=
name
.
split
(
"'"
)
print
(
'|
%
d |
%
s |
%
s |
%
s |'
%
(
msgid
,
envelope
.
subject
.
decode
(),
sender
[
1
],
envelope
.
date
))
print
(
"Type the number that corresponds to the email you wish to view, or type 0 for the menu."
)
viewOption
=
raw_input
(
"-->"
)
if
viewOption
==
"menu"
:
menuScreen
()
else
:
fullmsg
=
server
.
fetch
(
viewOption
,
[
'RFC822'
,
'BODY[TEXT]'
])
for
msgid
,
data
in
fullmsg
.
iteritems
():
parsedEmail
=
email
.
message_from_string
(
data
[
'RFC822'
])
body
=
email
.
message_from_string
(
data
[
'BODY[TEXT]'
])
parsedBody
=
parsedEmail
.
get_payload
(
0
)
print
parsedBody
print
(
"Return to menu? (Yes, No)"
)
temp
=
raw_input
(
"-->"
)
if
temp
==
"Yes"
or
"yes"
:
menuScreen
()
elif
temp
==
"No"
or
"no"
:
showInbox
()
else
:
server
.
logout
()
def
errhandler
():
print
(
"Enter a number that corresponds to an action."
)
menuScreen
()
def
menuScreen
():
print
(
"Type the corresponding number to the action you wish to perform."
)
print
(
"1 : Inbox"
)
print
(
"2 : Logout"
)
choice
=
input
(
"-->"
)
if
choice
==
1
:
showInbox
()
elif
choice
==
2
:
server
.
logout
()
else
:
errhandler
()
login
()
menuScreen
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment