diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-06-17 16:17:51 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-06-17 21:37:43 +0800 |
commit | 0824de3bae3550674a9ea029b03c5cb8a35cd8e1 (patch) | |
tree | 489af93f09449b6c0f9639e3fd2b2af7be25236d /deno/mail-relay/dovecot.ts | |
parent | e3acdfd274086a183402b2f0c75e54c620bf954a (diff) | |
download | crupest-0824de3bae3550674a9ea029b03c5cb8a35cd8e1.tar.gz crupest-0824de3bae3550674a9ea029b03c5cb8a35cd8e1.tar.bz2 crupest-0824de3bae3550674a9ea029b03c5cb8a35cd8e1.zip |
mail: try more to delete old sent, close connection in smtp server.
Diffstat (limited to 'deno/mail-relay/dovecot.ts')
-rw-r--r-- | deno/mail-relay/dovecot.ts | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/deno/mail-relay/dovecot.ts b/deno/mail-relay/dovecot.ts index e8469e6..55e1e9b 100644 --- a/deno/mail-relay/dovecot.ts +++ b/deno/mail-relay/dovecot.ts @@ -1,5 +1,3 @@ -import { basename } from "@std/path"; - import { Mail, MailDeliverContext, MailDeliverer } from "./mail.ts"; // https://doc.dovecot.org/main/core/man/dovecot-lda.1.html @@ -23,7 +21,7 @@ async function runCommand( ): Promise<CommandResult> { const { args, stdin, errorCodeMessageMap } = options; - console.info(`Run external command ${bin} ${args.join(" ")} ...`); + console.info(`Run external command ${bin} ${args.join(" ")}`); try { // Create and spawn process. @@ -89,7 +87,7 @@ export class DovecotMailDeliverer extends MailDeliverer { const recipients = [...context.recipients]; if (recipients.length === 0) { - context.result.message = + context.result.smtpMessage = "Failed to deliver to dovecot, no recipients are specified."; return; } @@ -196,12 +194,17 @@ export class DovecotMailDeliverer extends MailDeliverer { ); } - console.info("Schedule deletion of old mails at 15 seconds later."); - setTimeout(() => { - console.info( - "Try to delete mails in Sent box that has old message id.", - ); - void this.#deleteMail(from, "Sent", messageIdToDelete); - }, 1000 * 15); + console.info("Schedule deletion of old mails at 15,30,60 seconds later."); + [15, 30, 60].forEach((seconds) => + setTimeout(() => { + console.info( + `Try to delete mails in Sent. (message-id: ${messageIdToDelete}, ` + + `attempt delay: ${seconds}s) ` + + "Note that the mail may have already been deleted," + + " in which case failures of deletion can be just ignored.", + ); + void this.#deleteMail(from, "Sent", messageIdToDelete); + }, 1000 * seconds) + ); } } |