Closed umputun closed 2 years ago
related on completion of #1
Are there any requirements to api? I'm going to implement something like:
email.Params{From: "me@example.com", To: []string{"to@example.com"}, Subject: "Hello world!", Attachments: []email.Attachment{{path, inline}, {path, inline}})
type Attachment struct {
path string
inline bool
}
the end goal is to produce smth like this:
To: email@email.de
Subject: ...
Content-Type: multipart/related;
boundary="------------090303020209010600070908"
This is a multi-part message in MIME format.
--------------090303020209010600070908
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#ffffff" text="#000000">
<img src="cid:part1.06090408.01060107" alt="">
</body>
</html>
--------------090303020209010600070908
Content-Type: image/png;
name="moz-screenshot.png"
Content-Transfer-Encoding: base64
Content-ID: <part1.06090408.01060107>
Content-Disposition: inline;
filename="moz-screenshot.png"
[base64 image data here]
--------------090303020209010600070908--
Having the inline flag for each attached file seems strange, and I'm not sure what the use case for mixed "normal" and inline attachments. I can think of 2 methods here:
iinline
. This way user will able to form the actual html body referencing those images. cid:<filename>
another idea - maybe we should leave the current Attachments
filed alone, and add another one InlineImages
?
Ok, then. I'm adding InlineImages
option, and autogenerate CID from filename so that user can add image src to email body, right?
sounds good and easy to use
This is about cid and all of this, see for more info this article