High-performance SMTP mailer with queue management and OAuth2 support
- Features
- Quick Start
- Installation
- Configuration
- Usage
- Development
- Documentation
- Contributing
- License
- Optimized C++ Implementation: Built for speed and efficiency
- Parallel Processing: Multi-threaded email queue processing
- Memory Efficient: Smart memory management and resource handling
- Full SMTP Protocol: Complete RFC compliance
- Multiple Encryption: STARTTLS, SSL, and unencrypted connections
- Authentication Methods: PLAIN, LOGIN, CRAM-MD5, and OAuth2
- Connection Pooling: Efficient connection reuse and management
- Google Service Accounts: Native Gmail API support
- Microsoft Graph: Office 365 and Outlook integration
- Secure Token Management: Automatic token refresh and storage
- Multiple Providers: Extensible authentication framework
- Persistent Storage: Reliable email queuing with disk persistence
- Priority Handling: Configurable email priority levels
- Retry Logic: Intelligent retry with exponential backoff
- Dead Letter Queue: Failed email handling and analysis
- SSL/TLS Support: Modern encryption standards
- Certificate Validation: Proper SSL certificate verification
- Input Sanitization: Protection against injection attacks
- Logging & Monitoring: Comprehensive audit trails
- JSON Logging: Structured, machine-readable log output
- Event-Specific Logging: Email events, API requests, SMTP operations
- Configurable Fields: Choose which fields to include in logs
- Custom Metadata: Add application-specific fields to all log entries
- Integration Ready: Compatible with ELK Stack, Splunk, Grafana
- Performance Optimized: Minimal overhead for production use
- Background Processing: Run as a system daemon for continuous operation
- Queue Management: Automatic email queue processing in the background
- System Integration: Native systemd, launchd, and Windows Service support
- Signal Handling: Graceful shutdown and configuration reload support
- Process Management: PID file management and status checking
- Production Ready: Optimized for 24/7 operation
- macOS: Big Sur 11.0+ or later
- Linux: Ubuntu 20.04+, CentOS 8+, or compatible distributions
- C++ Compiler: GCC 9+ or Clang 12+
- CMake: 3.16 or later
# Clone the repository
git clone https://github.com/blburns/simple-smtp-mailer.git
cd simple-smtp-mailer
# Install dependencies
make deps
# Build with auto-detected architecture
make build-script
# Create installer package
make package-dmg
# Install (double-click the DMG or use installer)
sudo installer -pkg dist/simple-smtp-mailer-*.pkg -target /# Clone the repository
git clone https://github.com/blburns/simple-smtp-mailer.git
cd simple-smtp-mailer
# Install dependencies
make deps
# Build
make build
# Create platform-specific package
make package
# Install
sudo make install# Test installation
simple-smtp-mailer --version
# View help
simple-smtp-mailer --help
# Check configuration
simple-smtp-mailer --config-check- DMG Package: Drag-and-drop installation with GUI
- PKG Installer: Native macOS installer with post-install scripts
- Universal Binary: Intel + Apple Silicon compatibility
- DEB Package: Debian/Ubuntu family distributions
- RPM Package: Red Hat/CentOS/Fedora distributions
- Generic TGZ: Arch, Alpine, Gentoo, and other distributions
# macOS - Smart auto-detection
make build-script && make package-dmg
# Linux - Smart OS detection
make build && make package# Build from source
make clean && make build
# Install to system
sudo make install
# Create custom package
make package-custom/usr/local/bin/simple-smtp-mailer # Main executable
/usr/local/lib/libsimple-smtp-mailer.dylib # Shared library
/usr/local/include/simple-smtp-mailer/ # Header files
/etc/simple-smtp-mailer/ # Configuration files
/var/log/simple-smtp-mailer/ # Log files
# /etc/simple-smtp-mailer/simple-smtp-mailer.conf
[General]
log_level = INFO
log_file = /var/log/simple-smtp-mailer/simple-smtp-mailer.log
max_log_size = 10
max_log_files = 5
# JSON Logging Configuration
json_logging_enabled = true
json_log_fields = timestamp,level,message,thread,component,event_type
json_log_pretty_print = false
json_log_timestamp_format = %Y-%m-%dT%H:%M:%S.%fZ
[SMTP]
default_server = smtp.gmail.com
default_port = 587
default_encryption = STARTTLS
connection_timeout = 30
auth_timeout = 10
[Queue]
max_queue_size = 1000
retry_delay = 60
max_retries = 3
process_interval = 5
[Security]
verify_ssl = true
min_tls_version = 1.2# /etc/simple-smtp-mailer/auth/auth.conf
[Service_Accounts]
google_service_account_file = /path/to/service-account.json
google_scopes = https://www.googleapis.com/auth/gmail.send
microsoft_tenant_id = your-tenant-id
microsoft_client_id = your-client-id
microsoft_client_secret = your-client-secret# /etc/simple-smtp-mailer/templates/email.conf
[Templates]
welcome_subject = Welcome to our service
welcome_body = Thank you for joining our service!
notification_subject = Important notification
notification_body = You have an important notification.# Send a simple email
simple-smtp-mailer send --to user@example.com --subject "Hello" --body "Message body"
# Send with attachments
simple-smtp-mailer send --to user@example.com --subject "Report" --body "See attached" --attach report.pdf
# Send to multiple recipients
simple-smtp-mailer send --to user1@example.com,user2@example.com --subject "Group message" --body "Hello everyone"Run as a background daemon for continuous email processing:
# Start daemon
simple-smtp-mailer --daemon
# Check daemon status
simple-smtp-mailer --status
# Stop daemon
simple-smtp-mailer --stop
# Reload configuration
simple-smtp-mailer --reloadFor complete daemon documentation, see Daemon Mode Guide.
# List queued emails
simple-smtp-mailer queue list
# Show failed emails
simple-smtp-mailer queue failed
# Retry failed emails
simple-smtp-mailer queue retry
# Clear queue
simple-smtp-mailer queue clear# Validate configuration
simple-smtp-mailer config validate
# Test SMTP connection
simple-smtp-mailer config test-connection
# Show current settings
simple-smtp-mailer config show#include <simple-smtp-mailer/email.hpp>
#include <simple-smtp-mailer/mailer.hpp>
// Create email
ssmtp_mailer::Email email;
email.setFrom("sender@example.com");
email.addTo("recipient@example.com");
email.setSubject("Test Email");
email.setBody("Hello from simple-smtp-mailer!");
// Send email
ssmtp_mailer::Mailer mailer;
mailer.send(email);import ssmtp_mailer
# Create and send email
email = ssmtp_mailer.Email(
from_addr="sender@example.com",
to_addrs=["recipient@example.com"],
subject="Python Test",
body="Hello from Python!"
)
mailer = ssmtp_mailer.Mailer()
mailer.send(email)#include <simple-smtp-mailer/json_logger.hpp>
// Configure JSON logging
ssmtp_mailer::JsonLogConfig config;
config.enabled = true;
config.fields = "timestamp,level,message,thread,component,event_type";
config.custom_fields["service"] = "simple-smtp-mailer";
config.custom_fields["version"] = "0.2.0";
// Initialize logger
ssmtp_mailer::JsonLogger::initialize(config);
ssmtp_mailer::JsonLogger& logger = ssmtp_mailer::JsonLogger::getInstance();
// Log email events
logger.logEmailEvent(ssmtp_mailer::LogLevel::INFO, "sender@example.com",
{"recipient@example.com"}, "Welcome Email", "sent", "msg-12345");
// Log API requests
logger.logApiRequest(ssmtp_mailer::LogLevel::INFO, "SendGrid", "/v3/mail/send",
"POST", 200, 150);
// Structured logging
std::map<std::string, std::string> data = {
{"component", "smtp_client"},
{"action", "connect"},
{"server", "smtp.example.com"}
};
logger.logStructured(ssmtp_mailer::LogLevel::DEBUG, data);# macOS
xcode-select --install
brew install cmake openssl jsoncpp curl
# Ubuntu/Debian
sudo apt update
sudo apt install build-essential cmake libssl-dev libjsoncpp-dev libcurl4-openssl-dev
# CentOS/RHEL
sudo yum groupinstall "Development Tools"
sudo yum install cmake openssl-devel jsoncpp-devel libcurl-devel# Clean build
make clean
# Debug build
make debug
# Release build
make release
# Build with tests
make build && make test
# Run comprehensive test suite (58 tests)
cd build && ./tests/simple-smtp-mailer-tests
# Build specific architecture (macOS)
make build-intel # Intel only
make build-arm64 # Apple Silicon only
make build-universal # Both architectures# Code formatting
make format
# Style checking
make check-style
# Static analysis
make analyze
# Run tests
make test
# Run specific test suites
cd build && ./tests/simple-smtp-mailer-tests --gtest_filter="BasicFunctionalityTest.*"
cd build && ./tests/simple-smtp-mailer-tests --gtest_filter="*IntegrationTest.*"
# Build documentation
make docssimple-smtp-mailer/
βββ src/ # Source code
β βββ core/ # Core functionality
β β βββ auth/ # Authentication modules
β β βββ config/ # Configuration management
β β βββ logging/ # Logging system
β β βββ queue/ # Email queue management
β β βββ smtp/ # SMTP client implementation
β βββ email.cpp # Email class implementation
β βββ mailer.cpp # Main mailer class
β βββ main.cpp # Command-line interface
βββ include/ # Header files
βββ scripts/ # Build and installation scripts
βββ docs/ # Documentation
βββ tests/ # Google Test framework (58 tests, 7 suites)
βββ CMakeLists.txt # CMake configuration
βββ Makefile # Build automation
# Run all tests
make test
# Run specific test suite
make test-unit
make test-integration
make test-performance
# Generate coverage report
make coverage- Installation Guide:
docs/installation/ - Configuration Reference:
docs/configuration/ - API Documentation:
docs/api/ - Development Guide:
docs/development/
# Generate API docs
make docs-api
# Build user manual
make docs-manual
# Create PDF documentation
make docs-pdfWe welcome contributions! Here's how you can help:
- Fork the repository
- Clone your fork locally
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Follow the existing code style
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass
- Follow commit message conventions
- C++: Follow Google C++ Style Guide
- Naming: Use descriptive names and consistent conventions
- Comments: Document complex logic and public APIs
- Error Handling: Use proper error codes and logging
The project uses Google Test (gtest) for comprehensive testing:
- 68 tests across 8 test suites
- BasicFunctionalityTest: Core data structures and validation (12 tests)
- APIClientTest: API client factory and configuration (7 tests)
- ProviderIntegrationTest: Multi-provider testing (8 tests)
- HTTPClientTest: HTTP client functionality (8 tests)
- MailgunIntegrationTest: Mailgun API integration (7 tests)
- AmazonSESIntegrationTest: Amazon SES API integration (8 tests)
- SendGridIntegrationTest: SendGrid API integration (8 tests)
- JsonLoggingTest: JSON logging functionality (10 tests)
# Run all tests
cd build && ./tests/simple-smtp-mailer-tests
# Run specific test suite
cd build && ./tests/simple-smtp-mailer-tests --gtest_filter="BasicFunctionalityTest.*"
# Run with verbose output
cd build && ./tests/simple-smtp-mailer-tests --gtest_verbose- Unit Tests: Individual component testing with mocks
- Integration Tests: Multi-component interaction testing
- API Provider Tests: Provider-specific functionality testing
- Error Handling Tests: Comprehensive error scenario coverage
- Unit Tests: Required for all new functionality
- Integration Tests: For complex features
- Performance Tests: For performance-critical code
- Coverage: Maintain >80% test coverage
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
- OpenSSL: For cryptographic functionality
- libcurl: For HTTP/HTTPS support
- jsoncpp: For JSON parsing and generation
- CMake: For build system management
- Contributors: All who have helped improve this project
- Documentation: Check the docs/ directory
- Issues: Report bugs on GitHub Issues
- Discussions: Join conversations on GitHub Discussions
- Wiki: Check the GitHub Wiki
- GitHub: https://github.com/blburns/simple-smtp-mailer
- Issues: https://github.com/blburns/simple-smtp-mailer/issues
- Releases: https://github.com/blburns/simple-smtp-mailer/releases
Made with β€οΈ by the simple-smtp-mailer community
If you find this project useful, please consider giving it a β on GitHub!