-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/encoders & feat/related-attachments #63
base: main
Are you sure you want to change the base?
Conversation
31f37ca
to
fe9402b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR it looks proising!
But I request some changes to line this up with my coding style and revert some thing as I intended them...
Some general notes:
- Don't use
writeCMD
. Make more methods inside the SMTPClient class - In the config resolver the goal is that all keys exists with a good value so you don't have to do that inside the client. There are multiple instances of that. I commented on one of them
This was just a quick review in 5min and doesn't include a review of the new relatedAttachments implementation...
I also have to read through some specs to see if this implementation is correct etc. Will do this evening (UTC+1). |
56759bb
to
49c6457
Compare
49c6457
to
2306c62
Compare
2306c62
to
a34c1b7
Compare
The good:
The potentially bad:
The funny:
|
I allways squash merge so no "nice" history needed. |
I had a quick look and it looks quite good! I will need some time to test it and read some spec. I might add some changes on top of yours and do some renaming etc. where needed. So expect a merge in the next few days. |
I had a look at the code and it looks realy good! But I don't know if we need related-attachments: I pushed a fix to import { SMTPClient } from "./mod.ts";
const transport = new SMTPClient({
connection: {
hostname: "sandbox.smtp.mailtrap.io",
port: 25,
tls: false,
auth: {
username: "xxx",
password: "xxx"
}
},
debug: {
log: true,
noStartTLS: true,
allowUnsecure: true
}
})
transport.send({
to: "[email protected]",
html: '<p><b>Follow us on</b></p><p><a href=""><img src="cid:logo"></a></p>',
subject: "aaa",
from: "[email protected]",
attachments: [
{
filename: "test.png",
content: Deno.readFileSync("./test/e2e/attachments/image.png"),
encoding: "binary",
contentType: "image/png",
contentID: "logo"
}
]
}) And it works like you would expect! What is the difference? (My point is only about the related attachments the rest of the code I want to merge soon 👍 ) |
I quickly tested your example code and it did not work in all clients, most notably it did not work in Thunderbird. I can look into why it did not work further if requested. One remark to feat/attachment-content-id-fix: Actual differences PS: I also noticed a missing newline in my code to be spec compliant, I will fix it later |
Sorry for my inactivity on this matter, |
Hello. I feel I need to prefix this PR with a little justification: This PR has multiple parts to it and most of them should have been discussed in an Issue beforehand. But, since we needed these features fast I sadly did not have the time to do so before beginning development. I hope it can still be useful and understand that it may need reworking.
The goal of this PR was to allow users to embed images. This necessitated or at least encouraged multiple other changes.
feat/related-attachments
Implements
Content-Type: multiple/related
for mimeContent.To quote Wikipedia:
Minimal Example
Result:
Implementation
Added an optional field
relatedAttachments
onContent
. Also added an optional fieldrelatedAttachments
onSendConfig
that populates therelatedAttachments
field of the html mime entry upon being resolved.Then in
SMTPClient.send
check if there are relatedAttachments and if so use theencodeRelated
encoder to first encode the mimeContent itself and then the attachments inside aContent-Type: multipart/related
wrapper.feat/encoders
Since we also need to encode
Content
andAttachment
inside the related wrapper the functions have been refactored from the send method into theencode
folder. Additionally the unique boundary calculation has also been refactored here and now usesmatchAll
instead ofreplace
.