Open dbellingroth opened 3 years ago
It shouldn't be difficult. I contributed the Deno.startTLS function to complete this function. But I don’t currently have much energy to develop new features for open source projects
I tried to implement it myself using the following Code:
while (true) {
const cmd = await this.readCmd();
if (!cmd || !cmd.args.startsWith("-")) break;
if (cmd.args == "-STARTTLS") startTLS = true
}
if (startTLS) {
await this.writeCmd("STARTTLS")
this.assertCode(await this.readCmd(), CommandCode.READY)
this._conn = await Deno.startTls(this._conn, { hostname: config.hostname });
const reader = new BufReader(this._conn);
this._writer = new BufWriter(this._conn);
this._reader = new TextProtoReader(reader);
await this.writeCmd("EHLO", config.hostname);
while (true) {
const cmd = await this.readCmd();
if (!cmd || !cmd.args.startsWith("-")) break;
}
}
But I'm always getting an error message: error: Uncaught (in promise) UnexpectedEof: tls handshake eof await Deno.writeAll(
I tried to implement it myself using the following Code:
while (true) { const cmd = await this.readCmd(); if (!cmd || !cmd.args.startsWith("-")) break; if (cmd.args == "-STARTTLS") startTLS = true } if (startTLS) { await this.writeCmd("STARTTLS") this.assertCode(await this.readCmd(), CommandCode.READY) this._conn = await Deno.startTls(this._conn, { hostname: config.hostname }); const reader = new BufReader(this._conn); this._writer = new BufWriter(this._conn); this._reader = new TextProtoReader(reader); await this.writeCmd("EHLO", config.hostname); while (true) { const cmd = await this.readCmd(); if (!cmd || !cmd.args.startsWith("-")) break; } }
But I'm always getting an error message:
error: Uncaught (in promise) UnexpectedEof: tls handshake eof await Deno.writeAll(
OK. Seems like this is a problem with the mail server only supporting older cypher suites.
@dbellingroth works for me. I hope you don't mind I put it in a PR: https://github.com/manyuanrong/deno-smtp/pull/54
@dbellingroth works for me. I hope you don't mind I put it in a PR: #54
👍
How hard would it be to implement support for upgrading unencrypted connections via the STARTTLS command? Deno seems to include an new unstable API Deno.startTls which in theory should support upgrading connections.