如何解决AWS S3 存储图像链接在 Gmail 通讯中不起作用
我正在尝试使用 Django SMTP 发送时事通讯。但时事通讯中的图片链接在 Gmail 中已失效。
我使用的是自定义域名,图像存储在公共 S3 存储桶中。
时事通讯的 html 代码:
class Mail(generics.ListAPIView):
def post(self,request,*args,**kwargs):
subject = 'Newsletter'
message = ''
html_content = f'''
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Test</title>
</head>
<body>
<div style="width:100%;background-color:#F3F2EF;display:flex">
<div style="width:430px;display:block;margin:1rem auto;background-color:white;padding:1rem">
<div style="display:flex;height:60px;width:100%;align-items:center;">
<a href="https://www.example.com" style="display:flex;margin:auto"><img src="https://www.example.com/image.jpg" style="display:block" alt="logo" title="img" width="150px" height="50px" /></a>
</div>
</div>
</div>
</body>
</html>
'''
from_email = os.getenv('MAILADDRESS')
to = 'user@gmail.com'
msg = EmailMultiAlternatives(subject,message,from_email,[to])
msg.content_subtype = 'html'
msg.mixed_subtype = 'related'
msg.attach_alternative(html_content,"text/html")
msg.send()
return Response(status=status.HTTP_200_OK)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。