'End-point to receive mail from an external SMTP server.'

@http.route('/mail/receive', type='json', auth='none')
def receive(self, req):

    dbs = req.jsonrequest.get('databases')
    for db in dbs:
        message = dbs[db].decode('base64')
        try:
            db_registry = registry(db)
            with db_registry.cursor() as cr:
                env = api.Environment(cr, SUPERUSER_ID, {})
                env['mail.thread'].message_process(None, message)
        except psycopg2.Error:
            pass
    return True
