mirror of
https://github.com/neilalexander/yggmail.git
synced 2026-05-04 19:16:28 +03:00
Clean up destination queues when moving messages from Outbox
This commit is contained in:
@@ -326,6 +326,9 @@ func (mbox *Mailbox) MoveMessages(uid bool, seqset *imap.SeqSet, dest string) er
|
||||
if err := mbox.backend.Storage.MailMove(mbox.name, int(id), dest); err != nil {
|
||||
return err
|
||||
}
|
||||
if mbox.name == "Outbox" {
|
||||
mbox.backend.Storage.QueueDeleteDestinationForID("Outbox", int(id))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
package smtpsender
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/mail"
|
||||
@@ -112,14 +114,16 @@ func (q *Queue) run() {
|
||||
if err != nil {
|
||||
q.queues.Log.Println("Error with queue:", err)
|
||||
}
|
||||
|
||||
q.queues.Log.Println("There are", len(refs), "mail(s) queued for", q.destination)
|
||||
defer q.queues.Storage.MailExpunge("Outbox") // nolint:errcheck
|
||||
|
||||
for _, ref := range refs {
|
||||
_, mail, err := q.queues.Storage.MailSelect("Outbox", ref.ID)
|
||||
if err != nil {
|
||||
q.queues.Log.Println("Failed to get mail", ref.ID, "due to error:", err)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
q.queues.Storage.QueueDeleteDestinationForID("Outbox", ref.ID)
|
||||
} else {
|
||||
q.queues.Log.Println("Failed to get mail", ref.ID, "due to error:", err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user