第三方发送邮件配置
最常见的就是使用第三方的服务来配置发送邮件,以腾讯企业邮箱为例
Settings > Technical > Outgoing Mail Servers
SMTP Server: http://smtp.exmail.qq.com/
SMTP Port: 465
Connection Security:SSL/TLS
配置完成后点击下方 Test Connection 测试连接是否正常,正常会如图提示Connection Test Succeeded! Everything seems properly set up!
接收邮件配置相似,不再赘述。进行了如上配置后并非万事大吉了,我们会发现在发送邮件时提示错误:
1 2 3 4 5 |
Mail delivery failed via SMTP server 'None'. SMTPSenderRefused: 501 mail from address must be same as authorization user bounce+x-res.users-y@erp.alanhou.org # 以上x,y 分别为数字,x 为邮件流水号,y为单据流水号 |
如何解决呢?
方法一
1 2 3 4 5 |
odoo/addons/base/ir/ir_mail_server.py # 在第427行左右修改 smtp_from的值为对应配置的邮箱 smtp_from = from_rfc2822[-1] |
方法二
Settings > Technical > Parameters > System Parameters
1、确认mail.catchall.domain的域名与所配置域名是否相符
odoo/addons/base/ir/ir_mail_server.py文件中的_get_default_bounce_address方法可以查看拼接发送邮箱的源代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
@api.model def _get_default_bounce_address(self): '''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.bounce.alias" and "mail.catchall.domain". If "mail.bounce.alias" is not set it defaults to "postmaster-odoo". If "mail.catchall.domain" is not set, return None. ''' get_param = self.env['ir.config_parameter'].sudo().get_param postmaster = get_param('mail.bounce.alias', default='postmaster-odoo') domain = get_param('mail.catchall.domain') if postmaster and domain: return '%s@%s' % (postmaster, domain) |
2、创建一个 postmaster-odoo@yourdomain.com 的邮箱或修改此处的 default 值
3、删除mail.bounce.alias
注:同理接收邮箱配置参数为mail.catchall.alias
通过以上两种方法即可在 Odoo 中正常进行邮件的发送
TODO: Postfix配置本地邮件服务 Odoo测试