EC-Nordbund / denomailer

A SMTP-Client implementation for deno (to send mails!)
https://deno.land/x/denomailer
MIT License
50 stars 16 forks source link

STARTTLS is not working #66

Open mathe42 opened 1 year ago

mathe42 commented 1 year ago

Describe the bug

STARTTLS is not working

To Reproduce / minimal example

function sleep(to: number) {
    return new Promise((res)=>setTimeout(res, to))
}

const conn1 = await Deno.connect({
    hostname: "sandbox.smtp.mailtrap.io",
    port: 25
})

const enc = new TextEncoder()
await conn1.write(enc.encode("EHLO sandbox.smtp.mailtrap.io"))

// Wait until connection is ready for starttls
await sleep(2000)
await conn1.write(enc.encode("STARTTLS"))

const reader = conn1.readable.getReader()
// const reader = {read(){}}

// ??? What to put here

await Deno.startTls(conn1, {
    hostname: "sandbox.smtp.mailtrap.io"
})

// Make sure no GC is happening!
await reader.read()

The code needed at ??? is needed in client/base/connection.ts in line 40

Additional context

Reopens #65 and #59