Odoo将“postmaster”前缀添加到发件人地址

时间:2015-08-31 12:28:34

标签: odoo odoo-8

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

2 个答案:

答案 0 :(得分:5)

删除“设置”下的所有catchall参数(mail.catchall.domain和mail.catchall.alias) - > “技术” - > “参数” - > “系统参数”可以解决问题。

答案 1 :(得分:4)

我在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')

    # [...]

我想我没有忘记任何事情