我在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')
# [...]
我想我什么都没忘记