diff options
| author | Vidhin Mehta <vme@tinyerp.com> | 2013-08-23 10:36:02 +0530 |
|---|---|---|
| committer | Vidhin Mehta <vme@tinyerp.com> | 2013-08-23 10:36:02 +0530 |
| commit | 75ddd5ccbec73c4a671b6a74efaa3d41dc2ea2db (patch) | |
| tree | 50ed3620df15e8533760f5d47e754a1d39c1e856 /addons/mail/controllers/main.py | |
| parent | 42f27a15275effd9c43dfe99e32c395ca6b3fd8a (diff) | |
| parent | a7f4b6aaa0359d12046e81183417c24f093cd7c3 (diff) | |
[MERGE]Trunk.
bzr revid: vme@tinyerp.com-20130823050602-33bqv07e7g8dhv7x
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 |
