these four lines can become

    return remote_ip and remote_ip in settings.EMAIL_SERVER_WHITELIST