import re


def findExtendedCode(message):
    """get extended codes, which give more information than standard 3 digit codes
    
    Args:
        message: message from email server
    Returns:
        Extended code if found, None otherwise
    """
    
    #references:
    #https://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml
    #https://www.usps.org/info/smtp_status.html
    #https://docs.microsoft.com/en-us/exchange/mail-flow-best-practices/non-delivery-reports-in-exchange-online/non-delivery-reports-in-exchange-online
    
    #the first digit can be 2-5. Second digit can be 0-7. Third digit varies between servers.
    regex = '[2-5]\.[0-7]\.[0-9](([0-9])?)(([0-9])?)'
    
    #find such a pattern in the message
    x = re.search(regex, message)
    if x is not None:
        #return the first match
        return x.group(0)
    else:
        return None