Skip to content

Commit

Permalink
fix STARTTLS (fixes #59)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathe42 committed Feb 12, 2023
1 parent 4189e21 commit d37b3cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/basic/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ export class SMTPClient {
) {
this.#connection.writeCmdAndAssert(CommandCode.READY, "STARTTLS");

await this.#connection.cleanupForStartTLS()

const conn = await Deno.startTls(this.#connection.conn, {
hostname: this.config.connection.hostname,
});
Expand Down
6 changes: 6 additions & 0 deletions client/basic/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export class SMTPConnection {
this.#writer = this.#writableTransformStream.writable.getWriter();
}

async cleanupForStartTLS() {
await this.#reader.cancel()
await this.#writer.close()
}

async readLine() {
const ret = await this.#reader.read();
return ret.value ?? null;
Expand Down Expand Up @@ -66,6 +71,7 @@ export class SMTPConnection {
}
}


public assertCode(cmd: Command | null, code: number, msg?: string) {
if (!cmd) {
throw new Error(`invalid cmd`);
Expand Down

0 comments on commit d37b3cc

Please sign in to comment.