IMAP ingestion service that parses DMARC aggregate reports and submits data to the API.
  • Go 98.9%
  • Dockerfile 1.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nyaaan bc9cc95d21
All checks were successful
Bump Tag on Main / bump-tag (push) Successful in 9s
Go lint / lint (push) Successful in 2m16s
loader-dmarc-imap CI / build-and-push (push) Successful in 1m47s
fix: push tags via a credential-injected remote, not a reconstructed URL
GITHUB_SERVER_URL on this runner is an internal cluster address using
http:// (e.g. http://forgejo-http.forgejo.svc.cluster.local:3000), not
the public https:// hostname -- stripping only "https://" left it
untouched and produced "https://http://...". Instead of guessing at
scheme/host, read the remote URL checkout already resolved (proven to
work, since fetch/clone succeeded) and inject tag-bot credentials into
it directly. Also set persist-credentials: false on checkout so its
own token credentials cannot conflict with ours.
2026-08-28 04:26:55 +10:00
.forgejo/workflows fix: push tags via a credential-injected remote, not a reconstructed URL 2026-08-28 04:26:55 +10:00
.github/instructions inital commit 2026-05-05 17:16:01 +10:00
cmd/dmarc Replace interface{} with any in cmd/dmarc/main.go 2026-08-24 00:17:20 +10:00
docs Add backstage 2026-05-18 20:12:27 +10:00
internal Expand parser test coverage to the real MIME ingestion path 2026-08-24 01:33:40 +10:00
.dockerignore inital commit 2026-05-05 17:16:01 +10:00
.env.example added linter and stuff 2026-05-06 16:04:08 +10:00
.gitignore inital commit 2026-05-05 17:16:01 +10:00
catalog-info.yaml Add Backstage catalog metadata 2026-05-18 20:56:56 +10:00
Dockerfile fix: fully-qualify base images in Dockerfile 2026-08-27 18:02:42 +10:00
go.mod added linter and stuff 2026-05-06 16:04:08 +10:00
go.sum added linter and stuff 2026-05-06 16:04:08 +10:00
README.md docs: add Forgejo Actions status badges to README 2026-08-28 02:28:18 +10:00
renovate.json refactor: extend shared Renovate preset instead of duplicating config 2026-08-28 04:03:11 +10:00

loader-dmarc-imap

build-and-push lint

A small Go app that connects to an IMAP inbox, downloads messages, finds DMARC aggregate reports in XML/ZIP/GZIP attachments, and prints parsed report details to stdout.

This project uses Cobra CLI commands.

Requirements

  • Go 1.25+
  • IMAP account credentials

Configuration

Set environment variables for a single IMAP account:

  • IMAP_SERVER (required)
  • IMAP_PORT (optional, defaults to 993)
  • IMAP_USERNAME (required)
  • IMAP_PASSWORD (required)
  • IMAP_MAILBOX (optional, defaults to INBOX)
  • IMAP_SKIP_TLS_VERIFY (optional, defaults to false)
  • IMAP_ACCOUNT_NAME (optional, used for command filtering)
  • DEBUG (optional, defaults to false; when true, saves parsed DMARC XML files)
  • DEBUG_XML_DIR (optional, defaults to DEBUG/XML)

For multiple IMAP accounts, use indexed environment variables or a JSON array.

Example indexed account configuration:

IMAP_ACCOUNT_1_NAME=rua
IMAP_ACCOUNT_1_SERVER=imap.example.com
IMAP_ACCOUNT_1_PORT=993
IMAP_ACCOUNT_1_USERNAME=rua@example.com
IMAP_ACCOUNT_1_PASSWORD=secret
IMAP_ACCOUNT_1_MAILBOX=INBOX
IMAP_ACCOUNT_1_SKIP_TLS_VERIFY=false

IMAP_ACCOUNT_2_NAME=ruf
IMAP_ACCOUNT_2_SERVER=imap.example.com
IMAP_ACCOUNT_2_USERNAME=ruf@example.com
IMAP_ACCOUNT_2_PASSWORD=secret
IMAP_ACCOUNT_2_MAILBOX=INBOX

Example JSON configuration:

IMAP_ACCOUNTS=[
  {"name":"rua","server":"imap.example.com","port":993,"username":"rua@example.com","password":"secret","mailbox":"INBOX","skip_tls_verify":false},
  {"name":"ruf","server":"imap.example.com","username":"ruf@example.com","password":"secret","mailbox":"INBOX"}
]

The app automatically loads .env from the current working directory before reading environment variables. Existing exported environment variables still take precedence.

If a value contains special characters (for example #), wrap it in quotes in .env:

IMAP_PASSWORD="#SQNq8Qi*hKp4PQ$"

Run

cp .env.example .env
# edit .env values

go mod tidy
go run ./cmd/dmarc load --type=all
# or run a type-specific command
go run ./cmd/dmarc load-rua
go run ./cmd/dmarc load-ruf
go run ./cmd/dmarc load-tlsrpt

Build As dmarc

go build -o dmarc ./cmd/dmarc
./dmarc load

Project Structure

loader-dmarc-imap/
  cmd/dmarc/
    main.go                 # CLI entry point
  internal/
    config/
      config.go             # Configuration loading
    dmarc/
      types.go              # DMARC report data structures
      parser.go             # DMARC XML parsing and decompression
      debugxml.go           # Debug XML saving
      mail.go               # Email message parsing helpers
      time.go               # Time formatting utilities
    loader/
      loader.go             # IMAP connection and report fetching
  go.mod
  README.md

This project follows standard Go project layout conventions with CLI code in cmd/ and reusable packages in internal/.