def send(message, subject, to, to_name=None, sender=None, sender_name=None):
    """Send an email."""
    sender = sender or app.config.get('MAIL_FROM')
    sender_name = sender_name or app.config.get('MAIL_FROM_NAME') or ''
    mail_provider = app.config.get('MAIL_PROVIDER')
    if mail_provider is None:
        app.logger.error('No MAIL_PROVIDER configured!')
        raise MailFailure('No MAIL_PROVIDER configured!')
    elif mail_provider == 'smtp':
        _send_smtp(message, subject, to, to_name, sender, sender_name)
    elif mail_provider == 'mailjet':
        _send_mailjet(message, subject, to, to_name, sender, sender_name)
    else:
        app.logger.error('Invalid MAIL_PROVIDER configured!')
        raise MailFailure('Invalid MAIL_PROVIDER configured!')