'Catch IMAP, POP, and SMTP logins'

def mail_logins(self, full_load, src_ip_port, dst_ip_port, ack, seq):

    global mail_auths
    found = False
    full_load = self.double_line_checker(full_load, 'auth')
    if (src_ip_port in mail_auths):
        if (seq in mail_auths[src_ip_port][(-1)]):
            stripped = full_load.strip('\r\n')
            try:
                decoded = base64.b64decode(stripped)
                msg = ('Mail    authentication:    %s' % decoded)
                self.printer(src_ip_port, dst_ip_port, msg)
            except TypeError:
                pass
            mail_auths[src_ip_port].append(ack)
    elif (dst_ip_port in mail_auths):
        if (seq in mail_auths[dst_ip_port][(-1)]):
            a_s = 'Authentication    successful'
            a_f = 'Authentication    failed'
            if (full_load.startswith('235') and ('auth' in full_load.lower())):
                self.printer(dst_ip_port, src_ip_port, a_s)
                found = True
                try:
                    del mail_auths[dst_ip_port]
                except KeyError:
                    pass
            elif full_load.startswith('535    '):
                self.printer(dst_ip_port, src_ip_port, a_f)
                found = True
                try:
                    del mail_auths[dst_ip_port]
                except KeyError:
                    pass
            elif ('    fail' in full_load.lower()):
                self.printer(dst_ip_port, src_ip_port, a_f)
                found = True
                try:
                    del mail_auths[dst_ip_port]
                except KeyError:
                    pass
            elif ('    OK    [' in full_load):
                self.printer(dst_ip_port, src_ip_port, a_s)
                found = True
                try:
                    del mail_auths[dst_ip_port]
                except KeyError:
                    pass
            else:
                if (len(mail_auths) > 100):
                    mail_auths.popitem(last=False)
                mail_auths[dst_ip_port].append(ack)
    else:
        mail_auth_search = re.match(mail_auth_re, full_load, re.IGNORECASE)
        if (mail_auth_search != None):
            auth_msg = full_load
            if (mail_auth_search.group(1) != None):
                auth_msg = auth_msg.split()[1:]
            else:
                auth_msg = auth_msg.split()
            if (len(auth_msg) > 2):
                mail_creds = '    '.join(auth_msg[2:])
                msg = ('Mail    authentication:    %s' % mail_creds)
                self.printer(src_ip_port, dst_ip_port, msg)
                self.mail_decode(src_ip_port, dst_ip_port, mail_creds)
                try:
                    del mail_auths[src_ip_port]
                except KeyError:
                    pass
                found = True
            if (len(mail_auths) > 100):
                mail_auths.popitem(last=False)
            mail_auths[src_ip_port] = [ack]
        elif (re.match(mail_auth_re1, full_load, re.IGNORECASE) != None):
            auth_msg = full_load
            auth_msg = auth_msg.split()
            if (2 < len(auth_msg) < 5):
                mail_creds = '    '.join(auth_msg[2:])
                msg = ('Authentication:    %s' % mail_creds)
                self.printer(src_ip_port, dst_ip_port, msg)
                self.mail_decode(src_ip_port, dst_ip_port, mail_creds)
                found = True
    if (found == True):
        return True
