junk
Build Sieve filters that move suspected spam — failed SPF/DKIM, known spam phrases fetched from GoAdmio, known-bad sender IPs — into the Junk folder, or toggle the filter on and off
- Command:
/go/junk - Category: Mail
- Required option: None
- Output: None, except
Configuring IP Filter...during the main build - Last updated: 2026-11-21
On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also
Overview
/go/junk generates two Sieve filter scripts that doveconf wires into Dovecot when the junk filter is enabled: one general ruleset (.sieve) and one sender-IP blocklist (.ip). It can also just toggle the feature on or off.
[!WARNING] Both
sieveccalls that compile the generated scripts into the binary form Dovecot actually loads run withoutsudo, and this script has no root self-elevation check at the top. Every other command in the script (mkdir,tee,wget,cp) does usesudo. If this command is ever run without already being fully root, the human-readable.sieve/.ipfiles are updated correctly, but compiling them can fail silently — leaving Dovecot running whatever rules were compiled the last time this succeeded with full privileges, with no error shown. Confirm this script always runs as root.
[!NOTE] Running
/go/junk enableonly flips a database flag and restarts mail — it does not generate.sieve/.ipitself.doveconfonly wires the junk filter into Dovecot's configuration if those files already exist on disk. On a server where the no-argument form has never been run,enablehas no actual effect on mail filtering.
The call is appended to /var/log/go/junk.log.
Quick start
# Build (or rebuild) the filter rules
/go/junk
# Then turn the feature on
/go/junk enable
Syntax
/go/junk
/go/junk enable
/go/junk disable
| Form | Behavior |
|---|---|
/go/junk |
Regenerates /usr/local/goadmio/junk/.sieve and .ip from scratch and recompiles them. |
/go/junk enable |
Sets Junk=1 in GoAdmio's configuration, regenerates dovecot.conf with doveconf, and restarts mail in the background. |
/go/junk disable |
Same, with Junk=0. |
Options
None.
Output
Configuring IP Filter...
is the only line the main (no-argument) path prints. enable/disable print nothing of their own.
Examples
# First-time setup: build the rules, then turn the feature on
/go/junk
/go/junk enable
# Refresh the rules later (new spam phrases, new blocked IPs) and recompile them
/go/junk
# Turn it off
/go/junk disable
# Add an IP to the per-server blocklist the main path reads from
sudo sqlite3 /var/lib/sqlite/junk.db "INSERT INTO Junk (Domain, IP) VALUES ('example.com', '203.0.113.5')"
/go/junk
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
/go/junk enable doesn't seem to do anything |
The filter files were never generated. | Run /go/junk (no arguments) at least once first, then enable. |
| New spam phrases or IPs you just added don't seem to be filtered | The sievec compilation step may have failed silently (see the warning above), so Dovecot is still using an older compiled version. |
Confirm the command ran as root; check the actual compiled file's timestamp, and sievec's own exit status if you run it by hand. |
| Legitimate mail from a sender with no SPF record set up gets junked | SPF result None (no record published at all) is treated the same as Fail (an explicit failure) — see Known issues. |
This is a deliberate, if aggressive, policy choice; remove that rule from .sieve if it's too broad for your mail traffic. |
| An IP reported as spam for one domain gets blocked for every other hosted domain too | The IP blocklist is built server-wide; the Domain column in junk.db is read but not actually used to scope anything. |
Expected as currently written — see Known issues. There's no way to make a blocked IP apply to only one domain. |
The generated .sieve file fails to compile after an update |
A phrase fetched from GoAdmio's remote lists contained a double-quote character, which isn't escaped before being embedded in the Sieve file, corrupting its syntax. | Check /usr/local/goadmio/junk/.sieve for a broken string literal around where a new phrase was added, and run sievec by hand to see the error. |
download.goadmio.com related copies never happen |
That path only exists on GoAdmio's own distribution server; on an ordinary customer server, this step is a silent no-op. | Expected; not relevant to typical installs. |
Details
What the main path builds
.sieve (general rules, checked in order, each one stopping further processing if it matches):
Received-SPF: Fail→ JunkReceived-SPF: None→ Junk (see Known issues)Authentication-Resultscontainingdkim=fail→ Junk- Subject contains any of:
disk quota,storage is almost full, plus whatever lines are currently published athttps://www.goadmio.com/junk/subject.txt - Body contains any of:
advanced ai service,we are a leading software, plus whatever lines are currently published athttps://www.goadmio.com/junk/body.txt
.ip (sender IP blocklist):
- A hardcoded entry for
0.0.0.0 - Every syntactically IPv4-shaped value found in the
IPcolumn of GoAdmio's ownjunk.dbJunktable — across every domain, not scoped per-domain (see Known issues) - A hardcoded entry for
1.1.1.1(Cloudflare's public DNS resolver — it's unclear why this specific address is included; it may be a leftover placeholder, since it isn't a plausible mail-sending IP)
Both files are rebuilt from scratch every time, then compiled with sievec. If a server also hosts download.goadmio.com (GoAdmio's own infrastructure, not a typical customer server), the freshly built files are also copied there — presumably so the subject.txt/body.txt/IP lists can be served back out from that domain for other servers to fetch.
Why enable/disable restart mail but the main build doesn't
enable and disable change dovecot.conf itself (via doveconf), which needs Dovecot restarted to take effect — done in the background with screen, so the command returns immediately. The main build only changes the Sieve script content and recompiles it; Dovecot's Sieve plugin is normally re-checked per message delivery, so a successful recompile should take effect on the next incoming mail without a restart.
Known issues
- Both
sieveccalls run withoutsudo, the only commands in the script that don't, and there's no root-elevation guard at the top. See the warning above. enabledoesn't generate the filter files; it only flips the flag thatdoveconfchecks alongside file existence. See the note above.- SPF
Noneis treated as equivalent to SPFFail. Many legitimate senders simply don't publish an SPF record at all; this rule junks their mail just as aggressively as mail that explicitly fails SPF. - The IP blocklist ignores the
Domaincolumn it reads.junk.db's schema appears designed for per-domain blocking, but every matching IP, from any domain, ends up in one single, server-wide blocklist applied to all mailboxes. - Remote-fetched phrases aren't escaped for embedded quotes. A phrase containing a
"character, fetched from GoAdmio's subject or body lists, would break the quoted string it's placed into and corrupt the rest of the generated.sievefile. - The whitespace-trimming idiom (
echo $Content | xargs echo -n) uses unquoted expansion, which can unexpectedly glob-expand a phrase containing characters like*against files in the current directory. - IP format validation doesn't check octet ranges, so a value like
999.999.999.999would pass the "looks like an IPv4 address" check, though it would simply never match any real mail.
See also
| Command | Description |
|---|---|
doveconf |
Rebuild the Dovecot configuration for the installed Dovecot version, including SSL certificates for the hostname and each domain |
autoresponders |
Install the autoresponse Postfix content filter |
filter |
Manage per-domain email filters (Sieve) |
spam |
Track spam email accounts in GoAdmio |
installmail |
Install and configure webmail services (Postfix and Dovecot) |
troubleshoot |
Troubleshoot email problems in GoAdmio |