Community: Framework mailing list archives

expert-framework@mail.odoo.com

[PATCH] [WIP] Identifies with the SMTP server properly.

by Manuel Vázquez Acosta<manu@merchise.org> - 10/24/2014 15:26:13
From: Manuel Vázquez Acosta <mva.led@gmail.com>

---
 openerp/addons/base/ir/ir_mail_server.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/openerp/addons/base/ir/ir_mail_server.py b/openerp/addons/base/ir/ir_mail_server.py
index f2fa7a7..5ba0935 100644
--- a/openerp/addons/base/ir/ir_mail_server.py
+++ b/openerp/addons/base/ir/ir_mail_server.py
@@ -386,7 +386,14 @@ class ir_mail_server(osv.osv):
         :return: the Message-ID of the message that was just sent, if successfully sent, otherwise raises
                  MailDeliveryException and logs root cause.
         """
-        smtp_from = message['Return-Path'] or message['From']
+        # TODO: If the from address is not in the catchall domain.
+        _get_param = self.pool['ir.config_parameter'].get_param
+        catchall_alias = _get_param(cr, uid, "mail.catchall.alias", context=context)
+        catchall_domain = _get_param(cr, uid, "mail.catchall.domain", context=context)
+        if catchall_alias and catchall_domain:
+            message['Sender'] = '%s@%s' % (catchall_alias, catchall_domain)
+
+        smtp_from = message['Return-Path'] or message['Sender'] or message['From']
         assert smtp_from, "The Return-Path or From header is required for any outbound email"
 
         # The email's "Envelope From" (Return-Path), and all recipient addresses must only contain ASCII characters.
-- 
1.9.1