Skip to content

Conversation

@steffen-heil-secforge
Copy link

Summary

This PR adds server-side blacklist functionality to MailHog-Server, complementing the main MailHog application blacklist feature.

Changes Made

  • Config Enhancement: Added Blacklist field to Config struct for storing blacklisted email addresses
  • API v2 Endpoints: Added blacklist management 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 Session Validation: Enhanced SMTP session handling to validate sender/recipient against blacklist
  • Accept Function: Updated Accept() function signature to receive blacklist parameter

Technical Details

  • Thread-safe Operations: Uses map[string]bool for O(1) blacklist lookups
  • SMTP Integration: Validates both sender (validateSender) and recipient (validateRecipient) addresses
  • Backward Compatibility: Changes maintain API compatibility while adding new functionality

Integration

This PR works in conjunction with the main MailHog repository changes to provide complete blacklist functionality. The server-side components handle the core SMTP validation logic while the main application manages the user interface and configuration.

Files Modified

  • config/config.go - Added Blacklist field to Config struct
  • api/v2.go - Added blacklist API endpoints
  • smtp/session.go - Added blacklist validation to SMTP session
  • smtp/smtp.go - Updated Accept function call to pass blacklist

🤖 Generated with Claude Code

- 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>
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