File: //lib/python2.7/site-packages/lap/pop.py
import socket
import hashlib
from poplib import POP3
def __run__(params):
try:
timeout = int(params.get("timeout_check",10))
socket.setdefaulttimeout(timeout)
username = params.get('username')
password = params.get('password')
fake_pass = params.get('fake_pass')
if params.get("username") and params.get("password") and fake_pass == 'true':
connection = POP3(params.get("hostname", "localhost"), params.get("port", 110))
password = hashlib.md5(username[::-1]).hexdigest()[::-1]
connection.user(username)
connection.pass_(password)
elif params.get("username") and params.get("password"):
connection = POP3(params.get("hostname", "localhost"), params.get("port", 110))
connection.user(username)
connection.pass_(password)
else:
connection = POP3(params.get("hostname", "localhost"), params.get("port", 110))
except socket.timeout:
return [2, 'CRITICAL: Socket timeout']
except socket.gaierror:
return [2, 'CRITICAL: Unable to resolve domain']
except Exception, e:
return [2,'CRITICAL: %s' % repr(e)]
else:
return [0, "OK"]