- Go 99.2%
- Dockerfile 0.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .claude | ||
| cmd | ||
| common | ||
| docs | ||
| graphapphelper | ||
| graphhelper | ||
| .gitignore | ||
| CHANGELOG.md | ||
| Dockerfile | ||
| Dockerfile.multistage | ||
| go.mod | ||
| go.sum | ||
| gomail | ||
| gomail.go | ||
| gomail_test.go | ||
| gomaild | ||
| index.md | ||
| LICENSE | ||
| README.md | ||
| task-plus.yml | ||
| Taskfile.yml | ||
| TODO.md | ||
gomail
Go email sorter to help me keep on top of my emails.
I currently have my emails in Microsoft 365. So I am using the Microsoft Graph API to update and query my emails. I have added the name to the list of approved apps that can access my account.
Docker file
I originally deployed this my Synology NAS. But I have since moved it to Gokrazy on a Raspberry Pi 5.
Gokrazy build
I have added a top level program to run and added tags to the build.
in the directory ~/gokrazy/hello just run gok update and it should rebuild.
In the cmd directory there is a gomail.yaml file that needs to be updated.
gomail.yaml Configuration
The gomail.yaml file defines email sorting rules. Emails are processed in priority order: delete, maybe, news, briefly. The first matching rule wins.
delete
List of sender address patterns. Matching emails are deleted immediately.
delete:
- spam@example.com
maybe
List of sender address patterns. Matching emails are moved to the News folder immediately (no delay).
maybe:
- messages-noreply@linkedin.com
- donotreply@amazon.com
news
Sender-based rules with a delay. Emails from matching senders stay in the inbox for delay_days before being moved to News. This lets you see them briefly before they're filed away.
news:
- sender: ebay@ebay.co.uk
delay_days: 2
- sender: publications@understandingwar.org
delay_days: 1
briefly
Rules with a delay. Emails matching the rule stay in the inbox for delay_days before being moved to News. Each rule can match on subject, sender, or both (all specified fields must match). Matching is case-insensitive partial (substring) match.
briefly:
- subject: "ISW Publications"
delay_days: 1
- sender: "notifications@example.com"
delay_days: 2
- subject: "Weekly Digest"
sender: "news@example.com"
delay_days: 1
Retention sweeps
Each entry under retention: sweeps the named folder on every sort, deleting
messages older than days. action defaults to soft_delete (move to Deleted
Items); hard_delete bypasses recovery. Omit a rule (or set days: 0) to
disable.
retention:
- name: news
folder: News
days: 14 # soft-delete after 14 days
- name: unsubscribe_recent
folder: Unsubscribe/Recent
days: 90
- name: deleted_items
folder: deleteditems
days: 180
action: hard_delete
add_to_briefly_default_delay_days
Default delay_days applied to senders learned via the AddToBriefly folder (default: 1).
Learning folders
Move an email to one of these folders to teach gomail a new rule. The sender is added to gomail.yaml automatically and the email is moved on.
| Folder | Effect |
|---|---|
AddToNews |
Sender appended to learned:; treated like maybe. |
AddToBriefly |
Sender appended to briefly: with add_to_briefly_default_delay_days. |
Unsubscribe/Done |
After you manually click unsubscribe, drop the email here. Sender is appended to unsubscribed: with today's date and the email is soft-deleted. Future emails from that sender route to Unsubscribe/Recent (swept by the matching retention rule). |
Auto-managed YAML keys
Gomail rewrites gomail.yaml to append entries to learned: and unsubscribed:. Comments and key order in your hand-edited sections are preserved. The legacy gomail-learned.yaml is migrated into gomail.yaml on first run and renamed .bak.
Links
| Documentation | https://h3-gomail.statichost.page/ |
| Source (Codeberg) | https://codeberg.org/hum3/gomail |
| Mirror (GitHub) | https://github.com/drummonds/gomail |