Skip to content

Conversation

@steffen-heil-secforge
Copy link

Summary

This PR adds comprehensive email blacklist functionality to MailHog, allowing administrators to prevent specific email addresses from being processed by the SMTP server.

Features Added

  • Blacklist Configuration: New Blacklist field in Config struct to store blacklisted email addresses
  • API v2 Endpoints:
    • GET /api/v2/blacklist - List all blacklisted emails
    • POST /api/v2/blacklist/{email} - Add email to blacklist
    • DELETE /api/v2/blacklist/{email} - Remove email from blacklist
  • SMTP Validation: Enhanced Accept() function to reject emails to/from blacklisted addresses with proper SMTP error codes (550)
  • Documentation: Updated README and Swagger docs with blacklist functionality
  • Docker Compatibility: Fixed Dockerfile to ensure blacklist feature works in containerized environments

Use Cases

  • Block spam or unwanted email addresses during development testing
  • Simulate mail server rejection scenarios
  • Test error handling for blacklisted recipients/senders

Technical Details

  • Blacklisted emails are rejected at SMTP level with "550 Invalid recipient/sender" responses
  • Thread-safe implementation using map[string]bool for O(1) lookup performance
  • Backward compatible - existing functionality unchanged

Testing

The implementation has been tested with various scenarios including:

  • Adding/removing emails from blacklist via API
  • SMTP rejection of blacklisted sender/recipient addresses
  • Docker container functionality with Go 1.13 compatibility

🤖 Generated with Claude Code

steffen-heil-secforge and others added 3 commits August 10, 2025 21:32
- Add Blacklist map[string]bool to Config struct for storing blacklisted emails
- Add APIv2 endpoints: GET/POST/DELETE /api/v2/blacklist/{email}
- Add blacklist parameter to Accept() function for SMTP validation
- Reject emails to/from blacklisted addresses with 550 Invalid recipient/sender

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add blacklist API endpoints to Swagger documentation
- Update README with blacklist feature description
- Add v1.0.1 release notes for blacklist functionality
- Update Dockerfile to use secforge repository

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Change from golang:1.18-alpine to golang:1.13-alpine
- Use go get instead of go install for pre-modules compatibility
- Ensures vendor/ dependencies are used instead of downloading upstream modules
- Enables blacklist functionality to work in Docker builds

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@steffen-heil-secforge
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant