This guide explains how to use the web-based user interface for testing Mandrill email sending features.
The web UI provides an easy-to-use interface for testing all Mandrill email features without running PHP scripts directly from the command line. Built with PHP's built-in server, it offers a modern, responsive design.
cd scripts
composer installMake sure your .env file is configured in the scripts directory:
cp env.example .envEdit the .env file with your credentials:
MANDRILL_API_KEY=your_mandrill_api_key_here
DEFAULT_FROM_EMAIL=sender@yourdomain.com
DEFAULT_FROM_NAME="Your Name"
DEFAULT_TO_EMAIL=recipient@example.com
DEFAULT_TO_NAME="Recipient Name"Important: Always quote values that contain spaces or special characters. The PHP dotenv library strictly enforces this.
cd scripts
php -S localhost:8000You should see:
🚀 Mandrill Email Demo Web Application
============================================================
📧 Web server running...
🌐 Open your browser to: http://localhost:8000
💡 Press Ctrl+C to stop the server
Navigate to:
http://localhost:8000
The web UI provides access to all five email sending operations:
- Basic email sending demonstration
- Uses values from your
.envconfiguration - Perfect for testing basic setup
- Dynamic form fields for personalization
- Enter: First Name, Last Name, Company Name, Membership Level
- Demonstrates dynamic content replacement
- Sends emails with file attachments
- Demo includes PDF and text files
- Shows base64 encoding in action
- Choose between two pre-defined templates
- Visual template preview
- Demonstrates template-based email sending
- Comprehensive demo of all features combined
- Attachments, merge tags, metadata, tracking, etc.
- Shows the full power of the Mandrill API
The home page displays:
- Dropdown Menu: Select which email operation to test
- Description Box: Dynamic description of the selected operation
- Conditional Inputs: Form fields appear based on your selection
- Generate Button: Triggers the email sending process
After sending an email:
- Success Message: Green banner with success status
- Error Message: Red banner with error details
- Language: PHP 7.4+
- Web Server: PHP Built-in Server
- SDK: mailchimp/transactional
- Environment: vlucas/phpdotenv
- CSS: Custom responsive design
- User Selection: User selects an operation from the dropdown
- Dynamic UI: JavaScript shows/hides relevant form fields
- Form Submission: Form data is POST-ed to
/testEmailbasedOnScriptID - Script Execution: PHP backend calls the appropriate function
- Result Display: Success/error message is shown to the user
Error: Port already in use
lsof -ti:8000 | xargs kill -9
php -S localhost:8000# If dependencies missing:
composer install
# If autoload issues:
composer dump-autoloadCheck your .env file:
cat .envCommon Issues:
- Invalid API key
- Missing environment variables
- Invalid email addresses in
.env
For production use, consider:
- Authentication: Add user authentication
- Rate Limiting: Prevent abuse
- Input Validation: Sanitize all user inputs
- HTTPS: Use SSL/TLS in production
The UI is fully responsive and works on:
- 🖥️ Desktop computers
- 💻 Laptops
- 📱 Tablets
- 📱 Mobile phones
php -S localhost:9000Edit public/styles.css to customize colors, fonts, and layout.
Ready to test your emails?
cd scripts
php -S localhost:8000
# Open http://localhost:8000 in your browserHappy emailing! 📧✨