Support attachments with empty data
pandeyabs opened this issue · 3 comments
pandeyabs commented
Attach
returns an error here if an attachment file has no data. Is this by design? I don't see a reason why attachments can't be of size 0 bytes.
meain commented
diff --git a/attach.go b/attach.go
index 9aa48b6..809a8bb 100644
--- a/attach.go
+++ b/attach.go
@@ -108,7 +108,7 @@ func getAttachmentType(file *File) (attachType, error) {
return attachFile, nil
}
- return 0, errors.New("empty attachment")
+ return attachData, nil
}
// attachB64 does the low level attaching of the files but decoding base64
FYI, this will be the only change we need (maybe add check for existence of filename?). With this change it still generates valid .eml files (I tried a bunch of online viewers and it was able to parse them without issues). I can submit a PR if you want (and probably add a toggle as folks might also want to be warned about attaching a empty file).
xhit commented
A toggle SupportEmptyAttachments
should be added to avoid a breaking change. Feel free to send a PR. Thanks.