def METHOD_NAME(msg: EmailMessage):
    if not config.SMTP_SENDER_FALLBACK:
        # no fallback set, cannot rewrite. let's hope all emails go through...
        return
    from_email_raw = parser.get_mailbox(msg.from_email)[0].addr_spec  # just the addr without a name part
    if not any(fnmatch(from_email_raw, pattern) for pattern in config.SMTP_ALLOWED_SENDERS):
        msg.extra_headers['From'] = msg.from_email
        msg.from_email = config.SMTP_SENDER_FALLBACK