今天遇到一个问题, 在使用go发送带图片的html邮件时, 本来想直接在html中使用img标签, 然后用src=”https://xxxx.jpg”来发送图片, 但是后面发现不行, 默认邮件服务器似乎是为了安全, 会对src属性做转换, 所以图片链接转换以后无法正确渲染
后面研究下来, 是需要把图片作为附件发送, 然后在img标签中引用图片
<img src="cid:mail_open.jpg" width="561" height="151" alt="" />
email.Attach(&mail.File{
FilePath: "mail_open.jpg",
Name: "mail_open.jpg",
Inline: true,
})
<img src="cid:mail_open.jpg" width="561" height="151" alt="" />
email.Attach(&mail.File{
FilePath: "mail_open.jpg",
Name: "mail_open.jpg",
Inline: true,
})
<img src="cid:mail_open.jpg" width="561" height="151" alt="" /> email.Attach(&mail.File{ FilePath: "mail_open.jpg", Name: "mail_open.jpg", Inline: true, })
发表回复