<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def schedule_email(message, to, subject=None, sender=None, priority=None):
 """Schedules an email message for delivery. :param dict, str message: str or dict: use str for simple text email; dict - to compile email from a template (default: `sitemessage/messages/email_html__smtp.html`). :param list|str|unicode to: recipients addresses or Django User model heir instances :param str subject: email subject :param User sender: User model heir instance :param int priority: number describing message priority. If set overrides priority provided with message type. """


    if SHORTCUT_EMAIL_MESSAGE_TYPE:
        message_cls = get_registered_message_type(SHORTCUT_EMAIL_MESSAGE_TYPE)

    else:

        if isinstance(message, dict):
            message_cls = EmailHtmlMessage
        else:
            message_cls = EmailTextMessage

    schedule_messages(
        message_cls(subject, message),
        recipients(SHORTCUT_EMAIL_MESSENGER_TYPE, to),
        sender=sender, priority=priority
    )