Skip to content

Repository files navigation

ImapRSpamd

Bridge from IMAP to Rspamd

ImapRSpamd runs in the background and reads eMails from an IMAP mail server, pass it through Rspamd and update/copy/move/delete the message based on the spam score.

ImapRSpamd uses rspamd to get the spam score and distinguished between three states:

  • ham: The mail most likely is not a spam mail
  • tomato: The mail probably is a spam mail
  • spam: The mail most likely is a spam mail

Prerequisites

Build

  • Clone the repo
  • run "gradle build"

Usage

Usage: java -jar build/libs/ImapRSpamd-1.6.0-all.jar [options]
    Options:
    -cmd, --command             listFolders, learnSpam, learnHam, checkInbox, stat, idle
	listFolders: List the IMAP folders on the server
	learnSpam: Learn the mails from the spam folder as spam
	learnHam: Learn the mails from the ham folder as ham
	checkInbox: Check the mails in the inbox and perform the hamAction, tomatoAction or the spamAction
	stat: Show output of the rspamc stat command
	idle: Do not exit but wait for new mails

    -f, --force                 Process even already processed mails (default: false)
    --hamAction                 addHeader, rewriteSubject, update, move, copy, delete, trash, noop
	addHeader: Add the X-ImapRSpamd-XXX headers to the message
	rewriteSubject[1|2|3]: Replace the subject of the message
	update: Update the message (if changed)
	move: Move the message to the ham/tomato/spam folder
	copy: Copy the message to the ham/tomate/spam folder
	delete: Delete the message
	trash: Move the message to the trash folder
	noop: Do nothing

    --hamFolder                 Name of the HAM folder (default: ham)
    -h, --help                  Show this help
    -H, --host                  Host name
    --idleFolder                Name of the IDLE folder. Default: The same as --inboxFolder
    --idleTimeout               IDLE timeout in seconds. Default: 1790 (default: 1790)
    -i, --inboxFolder           Name of the INBOX folder (default: INBOX)
    --maxMessages               Process at most this many messages (default: 2147483647)
    --maxSize                   Maximum message size. Default: 1'048'576 bytes. (default: 1048576)
    --messageId                 Only process mails with given id
    --newSubject, --newSubject1 Rewritten subject. %s=original subject, %c=Score (default: [SPAM %c] %s)
    --newSubject2               First alternative for the rewritten subject. %s=original subject, %c=Score (default: 
                                [HAM %c] %s)
    --newSubject3               Second alternatoive for the rewritten subject. %s=original subject, %c=Score (default: 
                                [TOMATO %c] %s)
    -pw, --password             Password to login to the server
    -p, --port                  Port number (default: 993)
    --protocol                  Protocol: imap or imaps (default: imaps)
    --receivedDateAfter         Skip messages received before the date/time
    --receivedDateBefore        Skip messages received after the date/time
    --rspamc                    Commandline for rspamc (default: rspamc)
    --skipMessages              Skip that many messages (default: 0)
    --spamAction                addHeader, rewriteSubject, update, move, copy, delete, trash, noop (default: 
                                addHeader,move) 
    -s, --spamFolder            Name of the SPAM folder (default: Junk)
    --spamScore                 Spam score. Mails with a higher score are treated as spam (default: 18.0)
    --ssltrust                  Trust all SSL/TSL certificates
    --starttls                  Use STARTTLS (default: false)
    --systemd                   Run as a systemd service. Send watchdog messages. (default: false)
    --tomatoAction              addHeader, rewriteSubject, update, move, copy, delete, trash, noop (default: 
                                addHeader,move) 
    --tomatoFolder              Name of the TOMATO folder (default: Junk)
    --tomatoScore               Tomato score. Mails with a higer score are treated as tomato mails (default: 8.0)
    --trashFolder               Name of the TRASH folder (default: Trash)
    -u, --user                  User name to login to the server
    -v, --verbose               Be verbose (default: false)

Config files

All command line parameters may be written in one of the following files (Everything on a new line!):

/etc/imaprspamd/default.conf
~/default.conf
./default.conf
/etc/imaprspamd/local.conf
~/local.conf
./local.conf

default.conf

--rspamc
rspamc --pass-all
--inboxFolder
INBOX
--hamFolder
ham
--tomatoFolder
Junk
--spamFolder
spam-n042
--hamAction
addHeader
--tomatoAction
addHeader,move
--spamAction
addHeader,move

About

Bridge from IMAP to Rspamd

Topics

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages