def dkim_sign(message, dkim_domain=None, dkim_key=None, dkim_selector=None, dkim_headers=None):
    'Return signed email message if dkim package and settings are available.'
    try:
        import dkim
    except ImportError:
        pass
    else:
        if (dkim_domain and dkim_key):
            sig = dkim.sign(message, dkim_selector, dkim_domain, dkim_key, include_headers=dkim_headers)
            message = (sig + message)
    return message
Return signed email message if dkim package and settings are available.
def dkim_sign(message, dkim_domain=None, dkim_key=None, dkim_selector=None, dkim_headers=None):
    
    try:
        import dkim
    except ImportError:
        pass
    else:
        if (dkim_domain and dkim_key):
            sig = dkim.sign(message, dkim_selector, dkim_domain, dkim_key, include_headers=dkim_headers)
            message = (sig + message)
    return message