Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __terp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
'poweremail_template_view.xml',
'poweremail_send_wizard.xml',
'poweremail_mailbox_view.xml',
'poweremail_data.xml',
'poweremail_serveraction_view.xml'
],
"installable": True,
Expand Down
21 changes: 20 additions & 1 deletion poweremail_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from tools import config
import tools
import six

from ast import literal_eval as eval
from qreu import Email
from qreu.address import Address, parseaddr
from qreu.sendcontext import Sender, SMTPSender
Expand Down Expand Up @@ -532,6 +532,25 @@ def parse_sender(pem_account, pem_addresses):
"when the addresses list is empty").format(ids)
)
return error
varconf_o = self.pool.get('res.config')
blacklisted_recipients = set(eval(
varconf_o.get(cr, uid, 'poweremail_recipients_blacklist', '[]')
))
recipients = set(addresses_list.get('To', []) + addresses_list.get('CC', []) + addresses_list.get('BCC', []))
if len(blacklisted_recipients - recipients) != len(blacklisted_recipients):
error_mssg_blacklisted_recipients = _(
"ERROR: Trying to send an email to a blacklisted recipient:\n"
" - recipients: {}\n"
" - blacklisted recipients: {}"
).format(
", ".join(list(recipients)),
", ".join(list(blacklisted_recipients))
)
logger.notifyChannel(
_("Power Email"), netsvc.LOG_ERROR,
error_mssg_blacklisted_recipients
)
return Exception(error_mssg_blacklisted_recipients)
# Get email Data
subject = subject or context.get('subject', '') or ''
body_html = parse_body_html(
Expand Down
9 changes: 9 additions & 0 deletions poweremail_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record model="res.config" id="poweremail_recipients_blacklist">
<field name="name">poweremail_recipients_blacklist</field>
<field name="value">[]</field>
</record>
</data>
</openerp>