'Function to send Email
- simple Wrapper over Web2Py\'s Email API'

def send_email(self, to, subject, message, attachments=None, cc=None, bcc=None, reply_to=None, sender=None, encoding='utf-8'):

    if (not to):
        return False
    settings = current.deployment_settings
    default_sender = settings.get_mail_sender()
    if (not default_sender):
        current.log.warning('Email    sending    disabled    until    the    Sender    address    has    been    set    in    models/000_config.py')
        return False
    if (not sender):
        sender = default_sender
    sender = self.sanitize_sender(sender)
    limit = settings.get_mail_limit()
    if limit:
        day = datetime.timedelta(hours=24)
        cutoff = (current.request.utcnow - day)
        table = current.s3db.msg_channel_limit
        check = current.db((table.created_on > cutoff)).count()
        if (check >= limit):
            return False
        table.insert()
    result = current.mail.send(to, subject=subject, message=message, attachments=attachments, cc=cc, bcc=bcc, reply_to=reply_to, sender=sender, encoding=encoding, headers={})
    if (not result):
        current.session.error = current.mail.error
    else:
        current.session.error = None
    return result
