mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 16:33:47 +03:00
Add a 'KeepRejects' option that disables auto-cleanup (#49)
Add a 'KeepRejects' option that disables auto cleanup of the rejects mailbox.
This commit is contained in:
parent
e943e0c65d
commit
671fc5b8f1
3 changed files with 11 additions and 1 deletions
|
@ -300,6 +300,7 @@ type Account struct {
|
|||
Period time.Duration `sconf-doc:"How long unique values are accepted after generating, e.g. 12h."` // todo: have a reasonable default for this?
|
||||
} `sconf:"optional" sconf-doc:"If configured, messages classified as weakly spam are rejected with instructions to retry delivery, but this time with a signed token added to the subject. During the next delivery attempt, the signed token will bypass the spam filter. Messages with a clear spam signal, such as a known bad reputation, are rejected/delayed without a signed token."`
|
||||
RejectsMailbox string `sconf:"optional" sconf-doc:"Mail that looks like spam will be rejected, but a copy can be stored temporarily in a mailbox, e.g. Rejects. If mail isn't coming in when you expect, you can look there. The mail still isn't accepted, so the remote mail server may retry (hopefully, if legitimate), or give up (hopefully, if indeed a spammer). Messages are automatically removed from this mailbox, so do not set it to a mailbox that has messages you want to keep."`
|
||||
KeepRejects bool `sconf:"optional" sconf-doc:"Don't automatically delete mail in the RejectsMailbox listed above. This can be useful, e.g. for future spam training."`
|
||||
AutomaticJunkFlags struct {
|
||||
Enabled bool `sconf-doc:"If enabled, flags will be set automatically if they match a regular expression below. When two of the three mailbox regular expressions are set, the remaining one will match all unmatched messages. Messages are matched in the order specified and the search stops on the first match. Mailboxes are lowercased before matching."`
|
||||
JunkMailboxRegexp string `sconf:"optional" sconf-doc:"Example: ^(junk|spam)."`
|
||||
|
|
|
@ -692,6 +692,10 @@ describe-static" and "mox config describe-domains":
|
|||
# mailbox that has messages you want to keep. (optional)
|
||||
RejectsMailbox:
|
||||
|
||||
# If you'd like to retain the rejects described above instead of automatically
|
||||
# cleaning them (e.g. to train spam filters), you can set this to true. (optional)
|
||||
KeepRejects:
|
||||
|
||||
# Automatically set $Junk and $NotJunk flags based on mailbox messages are
|
||||
# delivered/moved/copied to. Email clients typically have too limited
|
||||
# functionality to conveniently set these flags, especially $NonJunk, but they can
|
||||
|
|
|
@ -2418,7 +2418,12 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
|
|||
m.MessageID = messageid
|
||||
m.MessageHash = messagehash
|
||||
acc.WithWLock(func() {
|
||||
if hasSpace, err := acc.TidyRejectsMailbox(c.log, conf.RejectsMailbox); err != nil {
|
||||
hasSpace := true
|
||||
var err error
|
||||
if !conf.KeepRejects {
|
||||
hasSpace, err = acc.TidyRejectsMailbox(c.log, conf.RejectsMailbox)
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorx("tidying rejects mailbox", err)
|
||||
} else if hasSpace {
|
||||
if err := acc.DeliverMailbox(log, conf.RejectsMailbox, m, dataFile, false); err != nil {
|
||||
|
|
Loading…
Reference in a new issue