diff options
Diffstat (limited to 'addons/mail/controllers')
| -rw-r--r-- | addons/mail/controllers/main.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py index 4c6f6e56064..ef3a60987d6 100644 --- a/addons/mail/controllers/main.py +++ b/addons/mail/controllers/main.py @@ -1,4 +1,7 @@ import base64 + +import openerp +from openerp import SUPERUSER_ID import openerp.addons.web.http as oeweb from openerp.addons.web.controllers.main import content_disposition @@ -20,3 +23,18 @@ class MailController(oeweb.Controller): headers=[('Content-Type', 'application/octet-stream'), ('Content-Disposition', content_disposition(filename, req))]) return req.not_found() + + @oeweb.jsonrequest + def receive(self, req): + """ End-point to receive mail from an external SMTP server. """ + dbs = req.jsonrequest.get('databases') + for db in dbs: + message = dbs[db].decode('base64') + try: + registry = openerp.registry(db) + with registry.cursor() as cr: + mail_thread = registry['mail.thread'] + mail_thread.message_process(cr, SUPERUSER_ID, None, message) + except psycopg2.Error: + pass + return True |
