[FIX] mail_tracking_mailgun: alternative domain
- In case the sending domain is different from the one configured in the mail.domain.catchall setting.
This commit is contained in:
parent
bf4687c4bb
commit
85beba204f
@ -36,6 +36,8 @@ parameters:
|
||||
domain.
|
||||
- `mailgun.api_url`: It should be fine as it is, but it could change in the
|
||||
future.
|
||||
- `mailgun.domain`: In case your sending domain is different from the one
|
||||
configured in `mail.catchall.domain`.
|
||||
- `mailgun.validation_key`: If you want to be able to check mail address
|
||||
validity you must config this parameter with your account Public Validation
|
||||
Key.
|
||||
|
@ -6,7 +6,7 @@
|
||||
{
|
||||
"name": "Mail tracking for Mailgun",
|
||||
"summary": "Mail tracking and Mailgun webhooks integration",
|
||||
"version": "11.0.1.0.3",
|
||||
"version": "11.0.1.1.2",
|
||||
"category": "Social Network",
|
||||
"website": "https://github.com/OCA/social",
|
||||
"author": "Tecnativa, "
|
||||
|
@ -14,25 +14,25 @@ msgstr ""
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:88
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:89
|
||||
#, python-format
|
||||
msgid "%s couldn't be verified. Either the request couln't be completed or the mailbox provider doesn't support email verification"
|
||||
msgstr ""
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:78
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:79
|
||||
#, python-format
|
||||
msgid "%s failed the mailbox verification. Please check it in order to avoid sending issues"
|
||||
msgstr ""
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:69
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:70
|
||||
#, python-format
|
||||
msgid "%s is not a valid email address. Please check it in order to avoid sending issues"
|
||||
msgstr ""
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/mail_tracking_email.py:75
|
||||
#: code:addons/mail_tracking_mailgun/models/mail_tracking_email.py:76
|
||||
#, python-format
|
||||
msgid "A Mailgun domain value is needed!"
|
||||
msgstr ""
|
||||
@ -53,7 +53,7 @@ msgid "Contact"
|
||||
msgstr ""
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/mail_tracking_email.py:238
|
||||
#: code:addons/mail_tracking_mailgun/models/mail_tracking_email.py:240
|
||||
#, python-format
|
||||
msgid "Couldn't retrieve Mailgun information"
|
||||
msgstr ""
|
||||
@ -67,13 +67,13 @@ msgid "Email has been bounced: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:56
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:57
|
||||
#, python-format
|
||||
msgid "Error %s trying to check mailof connection"
|
||||
msgstr ""
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/mail_tracking_email.py:242
|
||||
#: code:addons/mail_tracking_mailgun/models/mail_tracking_email.py:244
|
||||
#, python-format
|
||||
msgid "Event information not longer stored"
|
||||
msgstr ""
|
||||
@ -94,7 +94,7 @@ msgid "Mailgun"
|
||||
msgstr ""
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:63
|
||||
#: code:addons/mail_tracking_mailgun/models/res_partner.py:64
|
||||
#, python-format
|
||||
msgid "Mailgun Error. Mailbox verification value wasn't returned"
|
||||
msgstr ""
|
||||
@ -121,7 +121,7 @@ msgid "There is no Mailgun API key!"
|
||||
msgstr ""
|
||||
|
||||
#. module: mail_tracking_mailgun
|
||||
#: code:addons/mail_tracking_mailgun/models/mail_tracking_email.py:225
|
||||
#: code:addons/mail_tracking_mailgun/models/mail_tracking_email.py:227
|
||||
#, python-format
|
||||
msgid "There is no tracked message!"
|
||||
msgstr ""
|
||||
|
@ -64,13 +64,14 @@ class MailTrackingEmail(models.Model):
|
||||
digestmod=hashlib.sha256).hexdigest()
|
||||
|
||||
def _mailgun_values(self):
|
||||
icp = self.env['ir.config_parameter']
|
||||
icp = self.env['ir.config_parameter'].sudo()
|
||||
api_key = icp.get_param('mailgun.apikey')
|
||||
if not api_key:
|
||||
raise ValidationError(_('There is no Mailgun API key!'))
|
||||
api_url = icp.get_param(
|
||||
'mailgun.api_url', 'https://api.mailgun.net/v3')
|
||||
domain = icp.get_param('mail.catchall.domain')
|
||||
catchall_domain = icp.get_param('mail.catchall.domain')
|
||||
domain = icp.get_param('mailgun.domain', catchall_domain)
|
||||
if not domain:
|
||||
raise ValidationError(_('A Mailgun domain value is needed!'))
|
||||
validation_key = icp.get_param('mailgun.validation_key')
|
||||
@ -78,7 +79,8 @@ class MailTrackingEmail(models.Model):
|
||||
|
||||
def _mailgun_signature_verify(self, event):
|
||||
event = event or {}
|
||||
api_key = self.env['ir.config_parameter'].get_param('mailgun.apikey')
|
||||
icp = self.env['ir.config_parameter'].sudo()
|
||||
api_key = icp.get_param('mailgun.apikey')
|
||||
if not api_key:
|
||||
_logger.warning("No Mailgun api key configured. "
|
||||
"Please add 'mailgun.apikey' to System parameters "
|
||||
|
@ -46,7 +46,8 @@ class ResPartner(models.Model):
|
||||
' in order to be able to check mails validity'))
|
||||
for partner in self.filtered('email'):
|
||||
res = requests.get(
|
||||
"%s/address/validate" % api_url,
|
||||
# Validation API url is always the same
|
||||
'https://api.mailgun.net/v3/address/validate',
|
||||
auth=("api", validation_key), params={
|
||||
"address": partner.email,
|
||||
"mailbox_verification": True,
|
||||
|
@ -104,6 +104,11 @@ class TestMailgun(TransactionCase):
|
||||
self.test_event_delivered()
|
||||
with self.assertRaises(ValidationError):
|
||||
self.env['mail.tracking.email']._mailgun_values()
|
||||
# now we set an specific domain for Mailgun:
|
||||
# i.e: we configure new EU zone without loosing old domain statistics
|
||||
self.env['ir.config_parameter'].set_param(
|
||||
'mailgun.domain', 'eu.example.com')
|
||||
self.test_event_delivered()
|
||||
|
||||
@mute_logger('odoo.addons.mail_tracking_mailgun.models'
|
||||
'.mail_tracking_email')
|
||||
@ -169,7 +174,8 @@ class TestMailgun(TransactionCase):
|
||||
response = self.env['mail.tracking.email'].event_process(
|
||||
None, self.event, self.metadata)
|
||||
self.assertEqual('OK', response)
|
||||
event = self.event_search('delivered')
|
||||
events = self.event_search('delivered')
|
||||
for event in events:
|
||||
self.assertEqual(event.timestamp, float(self.timestamp))
|
||||
self.assertEqual(event.recipient, self.recipient)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user