Odoo 添加 "postmaster" 前缀到发件人地址

Odoo adds "postmaster" prefix to sender address

显然,ODOO 确实为外发电子邮件的发件人地址添加了 "postmaster" 前缀(例如 "postmaster-[user]@[domain]")。我怎样才能抑制这种行为?

删除 "Settings" -> "Technical" -> "Parameters" -> "System Parameters" 下的所有 catchall 参数(mail.catchall.domain 和 mail.catchall.alias)技巧。

我在 source code 中发现了一个错误。它使用 mail.bounce.alias 而不是 mail.catchall.alias

def _get_default_bounce_address(self, cr, uid, context=None):
    '''Compute the default bounce address.

    The default bounce address is used to set the envelop address if no
    envelop address is provided in the message.  It is formed by properly
    joining the parameters "mail.catchall.alias" and
    "mail.catchall.domain".

    If "mail.catchall.alias" is not set it defaults to "postmaster-odoo".

    If "mail.catchall.domain" is not set, return None.

    '''
    get_param = self.pool['ir.config_parameter'].get_param
    postmaster = get_param(cr, SUPERUSER_ID, 'mail.bounce.alias',
                            default='postmaster-odoo',
                            context=context,)
    domain = get_param(cr, SUPERUSER_ID, 'mail.catchall.domain', context=context)
    if postmaster and domain:
        return '%s@%s' % (postmaster, domain)

因此,如果您填写 mail.bounce.alias 应该可以。无论如何,我必须在源代码中修改一些东西才能让它按我想要的方式工作:

def send_email(self, cr, uid, message, mail_server_id=None, smtp_server=None, smtp_port=None,
               smtp_user=None, smtp_password=None, smtp_encryption=None, smtp_debug=False,
               context=None):

    smtp_from = self._get_default_bounce_address(cr, uid, context=context)
    if not smtp_from:
        smtp_from = message['From']   # this is only for the smtp
    assert smtp_from, "The Return-Path or From header is required for any outbound email"

    # [...]

也可以修改build_email方法中的email_from。但是你应该在Odoo配置文件中填写参数email_from

def build_email(self, email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False,
           attachments=None, message_id=None, references=None, object_id=False, subtype='plain', headers=None,
           body_alternative=None, subtype_alternative='plain'):

    email_from = tools.config.get('email_from')

    # [...]

我想我什么都没忘记