不能删除邮箱弹跳?

2024-05-15 16:50:18 发布

您现在位置:Python中文网/ 问答频道 /正文

在MailGun后端,我注意到了一个“未发送到以前弹出的地址”错误:

enter image description here

这可能是因为,在那个时候,电子邮件地址还没有设置好,但现在已经设置好了。因此,我想从先前弹出的地址列表中删除地址kurt@hicleo.com。在

https://documentation.mailgun.com/en/latest/api-bounces.html#bounces之后,我为发送方域get_bounces()实现了一个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()的结果中:

^{pr2}$

这里出什么问题了?在我看来,这是API参考中指令的正确Python实现:

enter image description here


Tags: inhttpscomapigetaddress电子邮件response
2条回答

您似乎已将bounces(在域和地址之间)留在URL之外。在

此外,可以使用MailGun的UI在“抑制”选项卡中轻松删除反弹,如下所示:

enter image description here

相关问题 更多 >