Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Python

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Home Popular Modules Log in Sign up (free)

Python poplib.POP3() Examples


Related Functions
The following are 50 code examples for showing how to use poplib.POP3(). They are extracted from open source Python
projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your sys.exit()
account. sys.argv()
re.compile()
+ Save to library time.time()
Example 1 os.listdir()
time.sleep()
re.search()
Project: 00scanner Author: xiaoqin00 File: mail.py (license) View Source Project 7 votes
os.remove()
def checkMailAccount(server,user,password,ssl=False,port=None): os.getcwd()
''' random.randint()
????Mail?????? time.strftime()
'''
datetime.timedelta()
if not port:
port = 995 if ssl else 110 threading.Thread()
socket.error()
try: socket.socket()
pop3 = poplib.POP3_SSL(server, port) if ssl else poplib. POP3(server, port) socket.SOCK_STREAM
hashlib.md5()
pop3.user(user)
threading.Lock()
auth = pop3.pass_(password)
smtplib.SMTP
pop3.quit()
except Exception as error: socket.gethostbyname()
#print "[!] chekcing {0} failed, reason:{1}".format(user, str(error))
return False

if "+OK" in auth:
return True
else:
return False

report this ad

Example 2 Related Modules

os
Project: code Author: ActiveState File: recipe-266480.py (MIT License) View Source Project 6 votes sys
def popPeek(server, user, port=110): re
time
try: logging
P = poplib. POP3(server, port) datetime
P.user(user) random
P.pass_(getpass.getpass())
urllib
except:
print "Failed to connect to server." string
sys.exit(1) socket
subprocess
deleted = 0 threading
struct
try:
base64
l = P.list()
smtplib
msgcount = len(l[1])
for i in range(msgcount):
msg = i+1 Others in poplib
top = P.top(msg, 0)
for line in top[1]: .error_proto()
print line .__all__()
input = raw_input("D to delete, any other key to leave message on server: ")
if input=="D":
P.dele(msg)
deleted += 1
P.quit()
print "%d messages deleted. %d messages left on server" % (deleted, msgcount-deleted)
except:
P.rset()
P.quit()
deleted = 0
print "\n%d messages deleted. %d messages left on server" % (deleted, msgcount-deleted)
Example 3

Project: code Author: ActiveState File: recipe-203610.py (MIT License) View Source Project 6 votes

def popauth(popHost, user, passwd):


"""
report this ad
Log in and log out, only to verify user identity.
Raise exception in case of failure.
"""
import poplib
try:
pop = poplib. POP3(popHost)
except:
raise StandardError, "Could not establish connection "+\
"to %s for password check" % popHost
try:
# Log in and perform a small sanity check
pop.user(user)
pop.pass_(passwd)
length, size = pop.stat()
assert type(length) == type(size) == type(0)
pop.quit()
except:
raise StandardError, "Could not verify identity. \n"+\
"User name %s or password incorrect." % user
pop.quit()
del pop

Example 4

Project: SPF Author: Exploit-install File: mailpillager.py (license) View Source Project 6 votes

def pillage(self, username, password, server, port, domain, outputdir="."):

print "%s, %s, %s, %s" % (username, password, server, domain)


mail = None
if (port == 993):
mail = IMAPS(outputdir=outputdir)
elif (port == 143):
mail = IMAP(outputdir=outputdir)
elif (port == 995):
mail = POP3S(outputdir=outputdir)
elif (port == 110):
mail = POP3(outputdir=outputdir)
else:
print "ERROR, unknown port provided"
return

mail.connect(server)
t = Thread(target=self.tworker, args=(mail, username, password, domain, server, port,))
t.start()

#-----------------------------------------------------------------------------
# main test code
#-----------------------------------------------------------------------------

Example 5

Project: darkc0de-old-stuff Author: tuwid File: popbrute.py (GNU General Public License v3.0) View
6 votes
Source Project

def run(self):
value, user = getword()
try:
print "-"*12
print "User:",user,"Password:",value
pop = poplib. POP3(sys.argv[1])
pop.user(user)
pop.pass_(value)
print "\t\nLogin successful:",value, user
print pop.stat()
pop.quit()
work.join()
sys.exit(2)
except (poplib.error_proto), msg:
#print "An error occurred:", msg
pass

Example 6

Project: darkc0de-old-stuff Author: tuwid File: popbrute_random.py (GNU General Public License
6 votes
v3.0) View Source Project

def run(self):
value = getword()
try:
print "-"*12
print "User:",user[:-1],"Password:",value
pop = poplib. POP3(ipaddr[0])
pop.user(user[:-1])
pop.pass_(value)
print "\t\nLogin successful:",value, user
print pop.stat()
pop.quit()
work.join()
sys.exit(2)
except(poplib.error_proto, socket.gaierror, socket.error, socket.herror), msg:
#print "An error occurred:", msg
pass

Example 7

Project: darkc0de-old-stuff Author: tuwid File: popbrute_iprange.py (GNU General Public License
6 votes
v3.0) View Source Project

def run(self):
value = getword()
try:
print "-"*12
print "User:",user[:-1],"Password:",value
pop = poplib. POP3(ip)
pop.user(user[:-1])
pop.pass_(value)
print "\t\nLogin successful:",value, user
print pop.stat()
pop.quit()
work.join()
sys.exit(2)
except(poplib.error_proto), msg:
#print "An error occurred:", msg
pass

Example 8

Project: prestashop-sync Author: dragoon File: check_for_articles_from_email.py (license) View


6 votes
Source Project

def connect(self):
"""Connects to and authenticates with a POP3 mail server"""

import poplib

M = None
try:
if (self.keyfile and self.certfile) or self.ssl:
M = poplib.POP3_SSL(self.host, self.port, self.keyfile, self.certfile)
else:
M = poplib. POP3(self.host, self.port)

M.user(self.username)
M.pass_(self.password)
except socket.error, err:
raise
else:
return M

Example 9

Project: fenghuangscanner_v3 Author: 0xwindows File: pop3.py (license) View Source Project 6 votes

def pop3_Connection(ip,username,password,port):
try:
pp = poplib. POP3(ip)
#pp.set_debuglevel(1)
pp.user(username)
pp.pass_(password)
(mailCount,size) = pp.stat()
pp.quit()
if mailCount:
lock.acquire()
printGreen("%s pop3 at %s has weaken password!!-------%s:%s\r\n" %
(ip,port,username,password))
result.append("%s pop3 at %s has weaken password!!-------%s:%s\r\n" %
(ip,port,username,password))
lock.release()
except Exception,e:
print e
lock.acquire()
print "%s pop3 service 's %s:%s login fail " %(ip,username,password)
lock.release()
pass

Example 10

Project: Judge Author: cobbr File: tasks.py (license) View Source Project 6 votes

def poll():
"""
Iterates over all the active services in the database and attempt to execute that service's
functionality.
The success or failure of the service and any error messages are stored in the database.
"""
for service in execute_db_query('select * from service where service_active = 1'):
sleep(2)
# Grab the service from the database
row = execute_db_query('select * from service_type join service ON
(service_type.service_type_id = service.service_type_id) where service.service_type_id = ?',
[service['service_type_id']])[0]
if row:
type = row['service_type_name']
# Perform DNS Request
if type == 'dns':
poll_dns.delay(timeout, service['service_id'], service['service_connection'],
service['service_request'], service['service_expected_result'])
# Perform HTTP(S) Request
elif type == 'http' or type == 'https':
poll_web.delay(timeout, service['service_id'], row['service_type_name'],
service['service_connection'], service['service_request'], service['service_expected_result'])
# Perform FTP Request
elif type == 'ftp':
poll_ftp.delay(timeout, service['service_id'], service['service_connection'],
service['service_request'], service['service_expected_result'])
# Perform SMTP request to send mail, POP3 to retrieve it back
elif type == 'mail':
poll_mail.delay(timeout, service['service_id'], service['service_connection'],
service['service_request'], service['service_expected_result'])

Example 11

Project: kekescan Author: xiaoxiaoleo File: pop3.py (license) View Source Project 6 votes
def pop3_Connection(ip,username,password,port):
try:
pp = poplib. POP3(ip)
#pp.set_debuglevel(1)
pp.user(username)
pp.pass_(password)
(mailCount,size) = pp.stat()
pp.quit()
if mailCount:
lock.acquire()
printGreen("%s pop3 at %s has weaken password!!-------%s:%s\r\n" %
(ip,port,username,password))
result.append("%s pop3 at %s has weaken password!!-------%s:%s\r\n" %
(ip,port,username,password))
lock.release()
except Exception,e:
print e
lock.acquire()
print "%s pop3 service 's %s:%s login fail " %(ip,username,password)
lock.release()
pass

Example 12

Project: PyQYT Author: cukewu File: POP3_REC_MAIL.py (license) View Source Project 6 votes

def qyt_rec_mail(mailserver, mailuser, mailpasswd, mailprefix):


print('Connecting...')
server = poplib. POP3(mailserver)
server.user(mailuser)
server.pass_(mailpasswd)

try:
print(server.getwelcome())
msgCount, msgBytes = server.stat()
print('There are', msgCount, 'mail message in', msgBytes, 'bytes')
print(server.list())

for i in range(msgCount):
hdr, message, octets = server.retr(i + 1)
mail_file_name = mailprefix + '_' + str(i+1) + '.txt'
mail_file = open(mail_file_name, 'wb')
for line in message:
mail_file.write(line)
mail_file.close()
print(mail_file_name + ' Recieved!!!')
finally:
server.quit()
print('Bye.')

Example 13

Project: vieterp-mailbox Author: vieterp File: fetchmail_server.py (license) View Source Project 6 votes

def connect(self):
if self.source_id and self.source_id.id:
self.ensure_one()
if self.source_id.type == 'imap':
if self.source_id.is_ssl:
connection = IMAP4_SSL(self.source_id.server, int(self.source_id.port))
else:
connection = IMAP4(self.source_id.server, int(self.source_id.port))
connection.login(self.user, self.password)
elif self.type == 'pop':
if self.source_id.is_ssl:
connection = POP3_SSL(self.source_id.server, int(self.source_id.port))
else:
connection = POP3(self.source_id.server, int(self.source_id.port))
# TODO: use this to remove only unread messages
# connection.user("recent:"+server.user)
connection.user(self.user)
connection.pass_(self.password)
# Add timeout on socket
connection.sock.settimeout(MAIL_TIMEOUT)
return connection
return super(vieterp_fetchmail_server, self).connect()

Example 14
Project: mailbrute Author: llq007 File: mailbrute.py (license) View Source Project 6 votes

def LoginServer(login_server,login_port,login_user,login_pass):
#login the server and return the login status
login_server_return=[False,False,'']
is_auth_user=False
try:
if login_port==995:
pop_login=poplib.POP3_SSL(login_server,login_port)
else:
pop_login=poplib. POP3(login_server,login_port)
user_auth=pop_login.user(login_user)
if "+OK" in user_auth.upper():
login_server_return[0]=True
is_auth_user=True
pass_auth=pop_login.pass_(login_pass)
if "+OK" in pass_auth.upper():
login_server_return[1]=True
login_server_return[2]="[-]Login is successful!"
pop_login.quit()
except Exception,e:
if not is_auth_user:
login_server_return[2]="Login user is not correct"
else:
login_server_return[2]=e
finally:
return login_server_return

Example 15

Project: PyQYT Author: collinsctk File: POP3_REC_MAIL.py (license) View Source Project 6 votes

def qyt_rec_mail(mailserver, mailuser, mailpasswd, mailprefix):


print('Connecting...')
server = poplib. POP3(mailserver)#????????
server.user(mailuser)#????????
server.pass_(mailpasswd)#???????

try:
print(server.getwelcome())#?????????
msgCount, msgBytes = server.stat()#??????????
print('There are', msgCount, 'mail message in', msgBytes, 'bytes')#??????????
print(server.list())#??????

for i in range(msgCount):#??????
hdr, message, octets = server.retr(i + 1)#????
mail_file_name = mailprefix + '_' + str(i+1) + '.txt'#???????
mail_file = open(mail_file_name, 'wb')#????????
for line in message:
mail_file.write(line)#???????????
mail_file.close()#?????????????
print(mail_file_name + ' Recieved!!!')
finally:
server.quit()#?????
print('Bye.')

Example 16

Project: SPF Author: Exploit-install File: mailpillager.py (license) View Source Project 5 votes

def connect(self, mailserver, port="993"):


self.mailserver = mailserver
self.port = port
try:
self.srv = imaplib.IMAP4_SSL(self.mailserver, self.port)
except:
self.srv = None
pass

#-----------------------------------------------------------------------------
# POP3 subclass of Pillager Class
#-----------------------------------------------------------------------------

Example 17

Project: SPF Author: Exploit-install File: mailpillager.py (license) View Source Project 5 votes
def connect(self, mailserver, port="110"):
self.mailserver = mailserver
self.port = port
try:
self.srv = poplib. POP3(self.mailserver, self.port)
except:
self.srv = None
pass

Example 18

Project: SPF Author: Exploit-install File: mailpillager.py (license) View Source Project 5 votes

def getMessages(self):
if (not self.srv):
return

if (not self.msg_list):
(numMsgs, totalSize) = self.srv.stat()
self.msg_list = []
for i in range(numMsgs):
self.msg_list.append(self.srv.retr(i+1))

#-----------------------------------------------------------------------------
# POP3S subclass of POP3 Class
#-----------------------------------------------------------------------------

Example 19

Project: SPF Author: Exploit-install File: mailpillager.py (license) View Source Project 5 votes

def __init__(self, outputdir="."):


POP3.__init__(self, outputdir)

Example 20

Project: prestashop-sync Author: dragoon File: check_for_articles_from_email.py (license) View


5 votes
Source Project

def fetch(self):
"""Fetches email messages from a POP3 server"""

messages = {}

num = len(self.handle.list()[1])
for i in range(num):
message = '\n'.join([msg for msg in self.handle.retr(i + 1)[1]])
messages[num] = self.parse_email(message)

return messages

Example 21

Project: prestashop-sync Author: dragoon File: check_for_articles_from_email.py (license) View


5 votes
Source Project

def disconnect(self):
"""Closes the POP3 handle"""

self.handle.quit()

Example 22

Project: zippy Author: securesystemslab File: test_poplib.py (license) View Source Project 5 votes

def found_terminator(self):
line = b''.join(self.in_buffer)
line = str(line, 'ISO-8859-1')
self.in_buffer = []
cmd = line.split(' ')[0].lower()
space = line.find(' ')
if space != -1:
arg = line[space + 1:]
else:
arg = ""
if hasattr(self, 'cmd_' + cmd):
method = getattr(self, 'cmd_' + cmd)
method(arg)
else:
self.push('-ERR unrecognized POP3 command "%s".' %cmd)

Example 23

Project: zippy Author: securesystemslab File: test_poplib.py (license) View Source Project 5 votes

def setUp(self):
self.server = DummyPOP3Server((HOST, PORT))
self.server.start()
self.client = poplib. POP3(self.server.host, self.server.port)

Example 24

Project: zippy Author: securesystemslab File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutDefault(self):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port)
finally:
socket.setdefaulttimeout(None)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 25

Project: zippy Author: securesystemslab File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutNone(self):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port, timeout=None)
finally:
socket.setdefaulttimeout(None)
self.assertTrue(pop.sock.gettimeout() is None)
pop.sock.close()

Example 26

Project: zippy Author: securesystemslab File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutValue(self):
pop = poplib. POP3(HOST, self.port, timeout=30)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 27

Project: oil Author: oilshell File: test_poplib.py (license) View Source Project 5 votes

def found_terminator(self):
line = ''.join(self.in_buffer)
self.in_buffer = []
cmd = line.split(' ')[0].lower()
space = line.find(' ')
if space != -1:
arg = line[space + 1:]
else:
arg = ""
if hasattr(self, 'cmd_' + cmd):
method = getattr(self, 'cmd_' + cmd)
method(arg)
else:
self.push('-ERR unrecognized POP3 command "%s".' %cmd)

Example 28

Project: oil Author: oilshell File: test_poplib.py (license) View Source Project 5 votes
def setUp(self):
self.server = DummyPOP3Server((HOST, 0))
self.server.start()
self.client = poplib. POP3(self.server.host, self.server.port)

Example 29

Project: oil Author: oilshell File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutDefault(self):
self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port)
finally:
socket.setdefaulttimeout(None)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 30

Project: oil Author: oilshell File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutNone(self):
self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port, timeout=None)
finally:
socket.setdefaulttimeout(None)
self.assertIsNone(pop.sock.gettimeout())
pop.sock.close()

Example 31

Project: oil Author: oilshell File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutValue(self):
pop = poplib. POP3(HOST, self.port, timeout=30)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 32

Project: python2-tracer Author: extremecoders-re File: test_poplib.py (license) View Source Project 5 votes

def found_terminator(self):
line = ''.join(self.in_buffer)
self.in_buffer = []
cmd = line.split(' ')[0].lower()
space = line.find(' ')
if space != -1:
arg = line[space + 1:]
else:
arg = ""
if hasattr(self, 'cmd_' + cmd):
method = getattr(self, 'cmd_' + cmd)
method(arg)
else:
self.push('-ERR unrecognized POP3 command "%s".' %cmd)

Example 33

Project: python2-tracer Author: extremecoders-re File: test_poplib.py (license) View Source Project 5 votes

def setUp(self):
self.server = DummyPOP3Server((HOST, 0))
self.server.start()
self.client = poplib. POP3(self.server.host, self.server.port)

Example 34

Project: python2-tracer Author: extremecoders-re File: test_poplib.py (license) View Source Project 5 votes
def testTimeoutDefault(self):
self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port)
finally:
socket.setdefaulttimeout(None)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 35

Project: python2-tracer Author: extremecoders-re File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutNone(self):
self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port, timeout=None)
finally:
socket.setdefaulttimeout(None)
self.assertIsNone(pop.sock.gettimeout())
pop.sock.close()

Example 36

Project: python2-tracer Author: extremecoders-re File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutValue(self):
pop = poplib. POP3(HOST, self.port, timeout=30)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 37

Project: PCControl Author: renhongl File: readEmail.py (license) View Source Project 5 votes

def downloadEmail(self):
print("Reading control command...")
server = poplib. POP3(self.pop3_server)
server.user(self.email)
server.pass_(self.pwd)
resp, mails, octets = server.list()
firstMail = len(mails)
resp, lines, octets = server.retr(firstMail)
msg_content = b'\r\n'.join(lines).decode('utf-8')
return msg_content

Example 38

Project: web_ctp Author: molebot File: test_poplib.py (license) View Source Project 5 votes

def found_terminator(self):
line = b''.join(self.in_buffer)
line = str(line, 'ISO-8859-1')
self.in_buffer = []
cmd = line.split(' ')[0].lower()
space = line.find(' ')
if space != -1:
arg = line[space + 1:]
else:
arg = ""
if hasattr(self, 'cmd_' + cmd):
method = getattr(self, 'cmd_' + cmd)
method(arg)
else:
self.push('-ERR unrecognized POP3 command "%s".' %cmd)

Example 39

Project: web_ctp Author: molebot File: test_poplib.py (license) View Source Project 5 votes

def setUp(self):
self.server = DummyPOP3Server((HOST, PORT))
self.server.start()
self.client = poplib. POP3(self.server.host, self.server.port, timeout=3)

Example 40

Project: web_ctp Author: molebot File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutDefault(self):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port)
finally:
socket.setdefaulttimeout(None)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 41

Project: web_ctp Author: molebot File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutNone(self):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port, timeout=None)
finally:
socket.setdefaulttimeout(None)
self.assertTrue(pop.sock.gettimeout() is None)
pop.sock.close()

Example 42

Project: web_ctp Author: molebot File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutValue(self):
pop = poplib. POP3(HOST, self.port, timeout=30)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 43

Project: pefile.pypy Author: cloudtracer File: test_poplib.py (license) View Source Project 5 votes

def found_terminator(self):
line = ''.join(self.in_buffer)
self.in_buffer = []
cmd = line.split(' ')[0].lower()
space = line.find(' ')
if space != -1:
arg = line[space + 1:]
else:
arg = ""
if hasattr(self, 'cmd_' + cmd):
method = getattr(self, 'cmd_' + cmd)
method(arg)
else:
self.push('-ERR unrecognized POP3 command "%s".' %cmd)

Example 44

Project: pefile.pypy Author: cloudtracer File: test_poplib.py (license) View Source Project 5 votes

def setUp(self):
self.server = DummyPOP3Server((HOST, 0))
self.server.start()
self.client = poplib. POP3(self.server.host, self.server.port)

Example 45

Project: pefile.pypy Author: cloudtracer File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutDefault(self):
self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port)
finally:
socket.setdefaulttimeout(None)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 46

Project: pefile.pypy Author: cloudtracer File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutNone(self):
self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
try:
pop = poplib. POP3(HOST, self.port, timeout=None)
finally:
socket.setdefaulttimeout(None)
self.assertIsNone(pop.sock.gettimeout())
pop.sock.close()

Example 47

Project: pefile.pypy Author: cloudtracer File: test_poplib.py (license) View Source Project 5 votes

def testTimeoutValue(self):
pop = poplib. POP3(HOST, self.port, timeout=30)
self.assertEqual(pop.sock.gettimeout(), 30)
pop.sock.close()

Example 48

Project: ouroboros Author: pybee File: test_poplib.py (license) View Source Project 5 votes

def found_terminator(self):
line = b''.join(self.in_buffer)
line = str(line, 'ISO-8859-1')
self.in_buffer = []
cmd = line.split(' ')[0].lower()
space = line.find(' ')
if space != -1:
arg = line[space + 1:]
else:
arg = ""
if hasattr(self, 'cmd_' + cmd):
method = getattr(self, 'cmd_' + cmd)
method(arg)
else:
self.push('-ERR unrecognized POP3 command "%s".' %cmd)

Example 49

Project: ouroboros Author: pybee File: test_poplib.py (license) View Source Project 5 votes

def setUp(self):
self.server = DummyPOP3Server((HOST, PORT))
self.server.start()
self.client = poplib. POP3(self.server.host, self.server.port, timeout=3)

Example 50

Project: ouroboros Author: pybee File: test_poplib.py (license) View Source Project 5 votes

def test_stls_context(self):
expected = b'+OK Begin TLS negotiation'
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
ctx.load_verify_locations(CAFILE)
ctx.verify_mode = ssl.CERT_REQUIRED
ctx.check_hostname = True
with self.assertRaises(ssl.CertificateError):
resp = self.client.stls(context=ctx)
self.client = poplib. POP3("localhost", self.server.port, timeout=3)
resp = self.client.stls(context=ctx)
self.assertEqual(resp, expected)
Terms of Use Privacy Support & Contact

You might also like