Gmail开放跟踪,使用Django设置Cookie

时间:2017-09-29 19:54:00

标签: python django email cookies gmail

我正在开发一个简单的应用程序,将透明像素嵌入到通过Gmail手动发送的电子邮件中,然后向用户添加cookie。

我将此<img>插入电子邮件中:

<img height="1" src="https://example.net/pixel.png?guid=1234" style="visibility:" width="1">

意图是当电子邮件打开时,它应该从example.net/pixel.png

请求图像

端点为pixel.png的Django应用程序具有以下视图:

def set_cookie(request):
    PIXEL_GIF_DATA = "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
    data = base64.b64decode(PIXEL_GIF_DATA)
    response = HttpResponse(data, content_type='image/gif')
    response.set_cookie('some_cookie_name', 'some_cookie_value')
    return response

如果我访问`example.net/pixel.png?guid=1234'它正在适当地设置cookie,所以我们在那里很好。

我遇到的唯一问题是,当电子邮件打开时,请求不会发送到我的服务器。作为收件人,如果我进入开发人员工具并观看网络请求,我没有看到对mysite.net的请求

但是,如果我查看原始电子邮件,则在页脚中我可以看到我的<img>标记已包含在内。

如果我尝试使用像static.example.net/images/sometest123.png这样的外部图像,则图像会通过并且可见。

1 个答案:

答案 0 :(得分:1)

Gmail fetches the image and caches it on its servers,以防止此类跟踪并保护收件人的隐私。