mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix email send
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
|
||||
{
|
||||
'name': "Sunpop Odooapp Common Func",
|
||||
'version': '16.23.05.04',
|
||||
'version': '16.23.05.09',
|
||||
'author': 'Sunpop.cn',
|
||||
'category': 'Base',
|
||||
'website': 'https://www.sunpop.cn',
|
||||
@@ -63,7 +63,7 @@
|
||||
5. Odoo 16, 企业版,社区版,多版本支持
|
||||
''',
|
||||
'depends': [
|
||||
'base',
|
||||
'mail',
|
||||
'web',
|
||||
],
|
||||
'data': [
|
||||
|
||||
@@ -27,5 +27,7 @@ from . import ir_ui_view
|
||||
from . import ir_cron
|
||||
from . import res_users
|
||||
from . import ir_mail_server
|
||||
from . import mail_mail
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class IrMailServer(models.Model):
|
||||
email_to = message['To']
|
||||
|
||||
# 忽略掉无效email,避免被ban
|
||||
if email_to.index('example.com') != -1 or email_to.index('@sunpop.cn') != -1 or email_to.index('@odooapp.cn') != -1:
|
||||
if email_to.find('example.com') != -1 or email_to.find('@sunpop.cn') != -1 or email_to.find('@odooapp.cn') != -1:
|
||||
_logger.error(_("=================Email to ignore: %s") % email_to)
|
||||
raise AssertionError(_("Email to ignore: %s") % email_to)
|
||||
|
||||
|
||||
16
app_common/models/mail_mail.py
Normal file
16
app_common/models/mail_mail.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class MailMail(models.Model):
|
||||
_inherit = "mail.mail"
|
||||
|
||||
# 猴子补丁模式,改默认发邮件逻辑
|
||||
def _send(self, auto_commit=False, raise_exception=False, smtp_session=None):
|
||||
for m in self:
|
||||
if m.email_to and (m.email_to.find('example.com') != -1 or m.email_to.find('@sunpop.cn') != -1 or m.email_to.find('@odooapp.cn') != -1):
|
||||
self = self - m
|
||||
return super(MailMail, self)._send(auto_commit, raise_exception, smtp_session)
|
||||
Reference in New Issue
Block a user