无法删除 MailGun 退回邮件?
Can't delete MailGun bounces?
在 MailGun 后端,我注意到一个 "Not delivering to previously bounced address" 错误:
这可能是因为当时邮箱地址还没有设置好,现在是了。因此,我想从之前退回的地址列表中删除地址 kurt@hicleo.com
。
在 https://documentation.mailgun.com/en/latest/api-bounces.html#bounces 之后,我为我们的发件人域 mg.startwithlucy.com
:
实施了 get_bounces()
方法
In [1]: import requests
In [2]: def get_bounces():
...: return requests.get('https://api.mailgun.net/v3/mg.startwithlucy.com
...: /bounces', auth=('api', '<our_api_key>')
...: )
...:
In [3]: response = get_bounces()
In [4]: response.status_code
Out[4]: 200
In [6]: import json
In [7]: content = json.loads(response.content)
In [14]: next(item for item in content['items'] if item['address'] == 'kurt@hicleo.com')
Out[14]:
{'MessageHash': '0f35b8112739c23d996bece18755de105a8422ad',
'address': 'kurt@hicleo.com',
'code': '550',
'created_at': 'Thu, 07 Jun 2018 17:48:28 UTC',
'error': 'No Such User Here'}
接下来,我定义了一个delete_bounce(address)
函数并为kurt@hicleo.com
调用了它。但是,我仍然看到相应的电子邮件地址显示在 get_bounces()
:
的结果中
In [21]: def delete_bounce(address):
...: return requests.delete(f'https://api.mailgun.net/v3/mg.startwithlucy.com/{address
...: }', auth=('api', '<our_api_key>'))
...:
In [22]: delete_response = delete_bounce('kurt@hicleo.com')
In [23]: delete_response.status_code
Out[23]: 200
In [24]: delete_response.content
Out[24]: b'Mailgun Magnificent API'
In [25]: response = get_bounces()
In [26]: response.status_code
Out[26]: 200
In [27]: content = json.loads(response.content)
In [28]: kurt_bounces = [item for item in content['items'] if item['address'] == 'kurt@hicleo.
...: com']
In [29]: kurt_bounces
Out[29]:
[{'MessageHash': '0f35b8112739c23d996bece18755de105a8422ad',
'address': 'kurt@hicleo.com',
'code': '550',
'created_at': 'Thu, 07 Jun 2018 17:48:28 UTC',
'error': 'No Such User Here'}]
这里出了什么问题?在我看来,这似乎是 API 参考文献中指令的正确 Python 实现:
您似乎已将 bounces
(域和地址之间)遗漏在 URL 之外。
此外,可以使用 MailGun 的 UI 轻松删除退回邮件,在 'Suppressions' 选项卡中,如下所示:
在 MailGun 后端,我注意到一个 "Not delivering to previously bounced address" 错误:
这可能是因为当时邮箱地址还没有设置好,现在是了。因此,我想从之前退回的地址列表中删除地址 kurt@hicleo.com
。
在 https://documentation.mailgun.com/en/latest/api-bounces.html#bounces 之后,我为我们的发件人域 mg.startwithlucy.com
:
get_bounces()
方法
In [1]: import requests
In [2]: def get_bounces():
...: return requests.get('https://api.mailgun.net/v3/mg.startwithlucy.com
...: /bounces', auth=('api', '<our_api_key>')
...: )
...:
In [3]: response = get_bounces()
In [4]: response.status_code
Out[4]: 200
In [6]: import json
In [7]: content = json.loads(response.content)
In [14]: next(item for item in content['items'] if item['address'] == 'kurt@hicleo.com')
Out[14]:
{'MessageHash': '0f35b8112739c23d996bece18755de105a8422ad',
'address': 'kurt@hicleo.com',
'code': '550',
'created_at': 'Thu, 07 Jun 2018 17:48:28 UTC',
'error': 'No Such User Here'}
接下来,我定义了一个delete_bounce(address)
函数并为kurt@hicleo.com
调用了它。但是,我仍然看到相应的电子邮件地址显示在 get_bounces()
:
In [21]: def delete_bounce(address):
...: return requests.delete(f'https://api.mailgun.net/v3/mg.startwithlucy.com/{address
...: }', auth=('api', '<our_api_key>'))
...:
In [22]: delete_response = delete_bounce('kurt@hicleo.com')
In [23]: delete_response.status_code
Out[23]: 200
In [24]: delete_response.content
Out[24]: b'Mailgun Magnificent API'
In [25]: response = get_bounces()
In [26]: response.status_code
Out[26]: 200
In [27]: content = json.loads(response.content)
In [28]: kurt_bounces = [item for item in content['items'] if item['address'] == 'kurt@hicleo.
...: com']
In [29]: kurt_bounces
Out[29]:
[{'MessageHash': '0f35b8112739c23d996bece18755de105a8422ad',
'address': 'kurt@hicleo.com',
'code': '550',
'created_at': 'Thu, 07 Jun 2018 17:48:28 UTC',
'error': 'No Such User Here'}]
这里出了什么问题?在我看来,这似乎是 API 参考文献中指令的正确 Python 实现:
您似乎已将 bounces
(域和地址之间)遗漏在 URL 之外。
此外,可以使用 MailGun 的 UI 轻松删除退回邮件,在 'Suppressions' 选项卡中,如下所示: