def serialize_email_messages(messages: List[EmailMessage]):
    """Serialize EmailMessages to be passed as task argument.

    Pickle is used because serializing an EmailMessage to json can be a bit
    tricky and would probably break if Django modifies the structure of the
    object in the future.
    """
    return [
        base64.b64encode(zlib.compress(pickle.dumps(m, protocol=4))).decode()
        for m in messages
    ]