- Go 98.9%
- Dockerfile 1.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
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. |
||
| .forgejo/workflows | ||
| .github/instructions | ||
| cmd/dmarc | ||
| docs | ||
| internal | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| catalog-info.yaml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
| renovate.json | ||
loader-dmarc-imap
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 to993)IMAP_USERNAME(required)IMAP_PASSWORD(required)IMAP_MAILBOX(optional, defaults toINBOX)IMAP_SKIP_TLS_VERIFY(optional, defaults tofalse)IMAP_ACCOUNT_NAME(optional, used for command filtering)DEBUG(optional, defaults tofalse; whentrue, saves parsed DMARC XML files)DEBUG_XML_DIR(optional, defaults toDEBUG/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/.