{"id":16842866,"url":"https://github.com/teverett/mailcradle","last_synced_at":"2025-04-11T05:52:57.178Z","repository":{"id":40309550,"uuid":"315469753","full_name":"teverett/mailcradle","owner":"teverett","description":"MailCradle server-side IMAP automated email processing system","archived":false,"fork":false,"pushed_at":"2025-04-01T05:46:12.000Z","size":582,"stargazers_count":3,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T05:52:42.509Z","etag":null,"topics":["email","imap"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teverett.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-23T23:53:02.000Z","updated_at":"2025-02-16T20:58:25.000Z","dependencies_parsed_at":"2024-06-09T15:54:52.279Z","dependency_job_id":"6d56d418-2f95-4da3-a9e9-7c1e21b5888e","html_url":"https://github.com/teverett/mailcradle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teverett%2Fmailcradle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teverett%2Fmailcradle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teverett%2Fmailcradle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teverett%2Fmailcradle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teverett","download_url":"https://codeload.github.com/teverett/mailcradle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351407,"owners_count":21089271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","imap"],"created_at":"2024-10-13T12:48:49.367Z","updated_at":"2025-04-11T05:52:57.157Z","avatar_url":"https://github.com/teverett.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/teverett/mailcradle/workflows/CI/badge.svg)\n\n\n# MailCradle\n\nMailCradle is a server-side system for sorting, deleting, and forwarding mail on an IMAP Server\n\n## Why is it named MailCradle?\n\nThere is mail that is important, and mail that can be read and responded to later.  Typically, I like to store the messages that need immediate attention in my INBOX, and automatically move all other mail into folders to process at a convenient time. In short, I want to separate the urgent mail from all other mail, and sort the mail that's not urgent.\n\nThe sorting process is similar to [winnowing](https://en.wikipedia.org/wiki/Winnowing), and that tool that has been used for centuries to winnow grain is a *cradle*.  Therefore, I named the program MailCradle.  Another name for a cradle is a [winnowing-fan](https://www.google.com/search?q=winnowing+fan), if you're interested to learn a bit about it.\n\n\n# Contributing\n\nMailCradle is a work in progress. Issues and Pull Requests are welcome.\n\n# License\n\nMailCradle is distributed under the 3-Clause BSD license.\n\n# Building MailCradle\n\nMailCradle builds with [maven](https://maven.apache.org/index.html) and requires Java11+.\n\nTo build MailCradle:\n\n`mvn clean package`\n\n# Running MailCradle\n\n`java -jar target/mailcradle-1.0.0-SNAPSHOT.jar --config=mailcradle.properties`\n\n# Configuration\n\nThe mail `mailcradle.properties` contains IMAP login properties, and the name of a mail sorting rules file. You will need to configure the properties file for your SMTP and IMAP server.\n\nHere's an example:\n\n```java\n# IMAP settings\nimap.host=mail.example.com\nimap.username=uuu\nimap.password=ppp\nimap.inbox=INBOX\nimap.crawlfolders=INBOX\nimap.crawlintervalhours=24\nimap.crawlRateSeconds=10\nimap.port=993\nimap.tls=true\nimap.keepaliveminutes=5\n\n# SMTP settings\nsmtp.host=mail.example.com\nsmtp.username=uuu\nsmtp.password=ppp\nsmtp.from=me@example.com\nsmtp.port=465\nsmtp.tls=true\n\n# rules file\nmailsortFile=mailcradle.txt\n```\n\n`imap.folders` is a comma-delimited list.  A trailing splat symbol `*` indicates to recurse folders under the parent folder.\n\n\n# Rules\n\nThere are two types of rules that MailCradle can process:\n\n* Simple Rules\n* List Rules\n\nThe full rule syntax in [ANTLR](https://www.antlr.org/) format is [here](https://github.com/teverett/mailcradle/blob/master/src/main/antlr4/com/khubla/mailcradle/mailcradle.g4).\n\nRules are run in the order that they are read from rule files, from top to bottom, including included rule files.\n\n## Simple Rules\n\nSimple rules take the format \n\n```java\nif (\u003cmaildata\u003e \u003ccondition\u003e \u003cvalue\u003e) {\n\t\u003cactions\u003e\n};\n```\n\nThe maildata fields can be:\n\n* subject\n* body\n* from\n* to\n* cc\n* bcc\n* header [\"fieldname\"]\n\nThe condition can be:\n\n* contains\n* is\n\nand `value` is a string such as \"me@here.com\".\n\n\n## List Rules\n\nList rules take the format\n\n```java\nif (\u003clistname\u003e contains \u003cvalue\u003e) {\n\t\u003cactions\u003e\n};\n```\n\nList rules require that a named list be defined to use. Lists are defined as:\n\n```java\nlist \u003clistname\u003e \"value1\", \"value2\", \"value3\", ... ;\n```\n\n## Expressions\n\nRules can be combined with the `and` and `or` operators and rule negation is supported via the `not` operator.\n\nThis rule finds all mail that is from me, to me, and moves it to a folder:\n\n```java\nif ((me contains from) and (me contains to)) {\n\tmoveto \"INBOX.Me\";\n};\n\nlist me\n\n\"tom@khubla.com\",\n\"tom@0x544745.com\";\n```\n\nThis rule finds all mail that is not addressed to me\n\n```java\nif (!(me contains to)) {\n\t// do stuff\n};\n\nlist me\n\n\"tom@khubla.com\",\n\"tom@0x544745.com\";\n```\n\n## Actions\n\nThere are numerous actions which can be run\n\n## moveto\n\nMove the message to an IMAP folder\n\n```java\nmoveto \u003cfoldername\u003e\n```\n\n**foldername** must be a quoted string such as \"me@example.com\".  If the target IMAP folder does not exists it is created and subscribed to.\n\n## replywith\n\nReply to the message\n\n```java\nreplywith \u003ccontent\u003e\n```\n\n**content** must be a quoted string such as \"This mailbox is not monitored\"\n\n\n## forwardto\n\nForward the message to an email address\n\n```java\nforwardto \u003caddress\u003e\n```\n\n**address** must be a quoted string such as \"someone@example.com\"\n\n## stop\n\nThe `stop` action stops all rule processing for a message.  It can be used to ensure that once a rule is run further rules are not run which would result in scenarios such as moving a message many times.\n\n## flag\n\nAdd an IMAP flag to the message.\n\n```java\nflag \u003cflagname\u003e\n```\n\n**flagname** must be a quoted string such as \"flagged\"\n\n\n## unflag\n\nRemove an IMAP flag from the message.\n\n```java\nunflag \u003cflagname\u003e\n```\n\n**flagname** must be a quoted string such as \"flagged\".  The standard flags which IMAP servers support are enumerated in [RFC 3501](https://tools.ietf.org/html/rfc3501)\n\n\n## Importing rule files\n\nRule files can include other rule files.  Simply use the `import` keyword\n\n\n```java\nimport \"family.txt\";\n```\n\n## Comments\n\nMailCradle rule files use the c-style `//` to indicate line comments. For example\n\n```java\n// this rules file contains a list of email addresses for family members\nimport \"family.txt\";\n```\n\n# Example rules\n\n## Example Files\n\nThe source tree contains example rule files in the directory [/examples](https://github.com/teverett/mailcradle/tree/master/examples).\n\n## Example Simple Rules\n\nA rule to move all email from \"@github.com\" to a folder called \"INBOX.github\"\n\n```java\nif (from contains \"@github.com\") {\n\tmoveto \"INBOX.github\";\n};\n```\n\nA rule to move all \"Free Money\" spam to the trash\n\n```java\nif (subject contains \"Free Money\") {\n\tmoveto \"INBOX.Trash\";\n};\n```\n\nAn out of office email\n\n```java\nif (from contains \"@example.com\") {\n\treplywith \"I am out of office\";\n};\n```\n\nMove all messages with the `X-Spam-Flag` header to \"YES\" to a folder\n\n```java\nif (header[\"X-Spam-Flag\"] is \"YES\") {\n\tmoveto \"INBOX.Spam\";\n};\n```\n\n## Example List rules\n\nA blackhole for spammers, using the subject field\n\n```java\nlist badsubjects \"$\", \"Money\", \"Free\";\nif (badsubjects contains subject) {\n\tmoveto \"INBOX.Trash\";\n};\n```\n\nMark all emails from a special list of senders with the IMAP \"flagged\" flag.\n\n```java\nlist importantpeople \"person1@example.com\", \"person2@example.com\", \"person3@example.com\";\nif (importantpeople contains from) {\n\tflag \"flagged\";\n};\n```\n\nForward all emails from certain domains and then save then in a folder\n\n```java\nlist domainlist \"@domain1.com\", \"@domain2.com\";\nif (domainlist contains from) {\n\tforwardto \"address@example.com\";\n\tmoveto \"INBOX.AutoForwarded\";\n};\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteverett%2Fmailcradle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteverett%2Fmailcradle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteverett%2Fmailcradle/lists"}