diff options
| author | sgo@tinyerp.com <> | 2013-06-26 16:40:29 +0530 |
|---|---|---|
| committer | sgo@tinyerp.com <> | 2013-06-26 16:40:29 +0530 |
| commit | 2e272a76872cee16de1ecbdc8f67fdf4a84f27e4 (patch) | |
| tree | 73883be0a6ba0f3ad7f0ee6299db56279d471c6b /addons/mail/controllers/main.py | |
| parent | 2ed45d19d31344e332ae3632abec8c791efab1f0 (diff) | |
| parent | c180afab26171617c1c7c22db5d9836b159e5e7d (diff) | |
[MERGE]sync with trunk
bzr revid: sgo@tinyerp.com-20130626111029-e6szwugpewn3cd2g
Diffstat (limited to 'addons/mail/controllers/main.py')
| -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 |
