# PHP Bulk Email Sender with Professional Template A complete PHP solution for sending personalized bulk emails to customers with a beautiful white-themed email template featuring logo, product images, purchase buttons, and company information. ## 📋 Features - 🖼️ **Product Image Upload**: Upload and manage multiple product images with drag & drop interface - 📸 **Multi-Image Email Support**: Display multiple product images in beautiful grid layout - 💾 **Image Storage**: Automatically stores uploaded images locally and generates URLs - 🎨 **Web-Based Product Manager**: Easy-to-use interface for managing products - ✉️ **Professional Email Template**: Clean white design with responsive layout - 🎯 **Email-Safe Design**: No JavaScript - works in all email clients - 📦 **Bulk Email Support**: Send to multiple recipients with batch processing - ⚙️ **SMTP Configuration**: Works with any SMTP server (Gmail, SendGrid, etc.) - 📊 **CSV Import**: Load customer lists from CSV files - 🔄 **Rate Limiting**: Configurable delays to avoid spam filters - 📈 **Campaign Tracking**: Real-time progress and detailed summary reports ## 🚀 Quick Start ### Prerequisites - PHP 7.4 or higher - Composer (PHP package manager) - SMTP email account (Gmail, Outlook, SendGrid, etc.) ### Installation 1. **Install PHPMailer via Composer** Open PowerShell in the project directory and run: ```powershell composer require phpmailer/phpmailer ``` 2. **Configure SMTP Settings** Edit `config/config.php` and update with your SMTP credentials: ```php 'smtp' => [ 'host' => 'smtp.gmail.com', 'port' => 587, 'encryption' => 'tls', 'username' => 'your-email@example.com', 'password' => 'your-app-password', ], ``` 3. **Update Company Information** In `config/config.php`, update your company details: ```php 'company' => [ 'name' => 'Your Company Name', 'logo_url' => 'https://yourwebsite.com/assets/logo.png', 'website' => 'https://yourwebsite.com', 'description' => 'Your trusted partner...', // ... more fields ], ``` ## 📧 Usage ### Step 1: Add Products with Images 1. **Start a local PHP server**: ```powershell cd "c:\Rohan\Lorvantiq Ventures\SaroGenix\Code" php -S localhost:8000 ``` 2. **Open Product Manager** in your browser: ``` http://localhost:8000/product_manager.html ``` 3. **Add a new product**: - Enter product name, description, price, and link - Drag & drop or browse multiple product images - Click "Save Product" - Images are automatically stored in `uploads/products/` ### Step 2: Send Emails 1. **Open Email Sender**: ``` http://localhost:8000/send_emails_ui.php ``` 2. **Select a product** from the dropdown (or click "Use in Email" from Product Manager) 3. **Add recipients**: - Manually add recipients one by one - Or upload a CSV file with recipients 4. **Send emails**: - Click "Send Test Email" to test first - Click "Send Bulk Emails" to send to all recipients ### Alternative: Command Line Usage Edit `send_bulk_emails.php` and uncomment the test email section: ```php // Initialize the sender $sender = new BulkEmailSender(); // Send test email with saved product $recipients = [ ['email' => 'test@example.com', 'name' => 'Test User'] ]; $sender->sendBulkEmailsWithProduct(1, $recipients); // Product ID = 1 ``` Run in PowerShell: ```powershell php send_bulk_emails.php ``` ## 📁 Project Structure ``` Code/ ├── config/ │ └── config.php # SMTP and company configuration ├── templates/ │ ├── email_template.php # Single image email template │ └── email_template_multi_image.php # Multi-image email template ├── data/ │ ├── customers.csv # Customer list (CSV format) │ └── products.json # Saved products database ├── uploads/ │ └── products/ # Uploaded product images ├── product_manager.html # Product management interface ├── send_emails_ui.php # Email sending interface ├── upload_product.php # Product upload handler ├── get_products.php # Get products API ├── delete_product.php # Delete product API ├── process_bulk_send.php # Bulk email processor ├── send_bulk_emails.php # Main bulk email sender class ├── example_usage.php # Usage examples ├── composer.json # PHP dependencies └── README.md # This file ``` ## 🎨 Email Template Features - **Header Section**: Company logo with clean white background - **Greeting**: Personalized customer name - **Product Showcase**: - **Multiple product images** displayed in responsive grid - Main featured image + up to 3 additional images per row - All images are clickable and link to product page - Product name and description - Prominent price display - **Call-to-Action**: Green "Buy Now" button - **Footer**: - Company information and description - Contact details (address, phone, email) - Copyright notice - Unsubscribe links ### 📸 Multi-Image Display The email template automatically handles multiple product images: - **1 image**: Displays single large image - **2-3 images**: Main image + smaller images in a row - **4+ images**: Main image + grid of additional images (3 per row) - All images are **email-safe** (no JavaScript required) - Works in all email clients (Gmail, Outlook, Apple Mail, etc.) ## ⚙️ Configuration Options ### Email Settings In `config/config.php`: ```php 'email' => [ 'batch_size' => 50, // Emails per batch 'delay_between_batches' => 5, // Seconds between batches 'delay_between_emails' => 1, // Seconds between individual emails ], ``` ### CSV Format for Recipients When uploading recipient list in the UI: - `email`: Recipient email address - `name`: Customer name - `subject`: Email subject line (optional) Example: ```csv email,name,subject john@example.com,John Doe,Special Offer jane@example.com,Jane Smith,Check this out! ``` ### Image Upload Guidelines - **Supported formats**: JPG, PNG, GIF, WebP - **Max file size**: 5MB per image - **Recommended size**: 800x600px or larger for best quality - **Multiple images**: Upload 1-5 images per product - Images are automatically stored in `uploads/products/` - Full URLs are generated automatically for email embedding ## 🔒 Gmail Setup (If Using Gmail SMTP) 1. Enable 2-Factor Authentication on your Google Account 2. Generate an App Password: - Go to Google Account → Security → 2-Step Verification → App passwords - Select "Mail" and "Windows Computer" - Copy the generated 16-character password 3. Use this app password in `config/config.php` ## 🎯 Best Practices 1. **Test First**: Always send a test email before bulk sending 2. **Verify SMTP**: Ensure SMTP credentials are correct 3. **Optimize Images**: - Use compressed images (under 500KB each) - Recommended dimensions: 800x600px - Use web-optimized formats (JPG for photos, PNG for graphics) 4. **Check Spam Filters**: Test emails may go to spam initially 5. **Respect Limits**: Adjust batch sizes based on your SMTP provider's limits 6. **Store Images Properly**: Keep uploaded images in `uploads/products/` directory 7. **Use Multiple Images**: Show different product angles for better engagement 8. **Personalize**: Customize the template to match your brand 9. **Compliance**: Include unsubscribe links and comply with email regulations ## ❓ FAQ ### Can I use animated GIFs or image sliders in emails? **Static multi-images: YES ✅** | **Animated sliders with JavaScript: NO ❌** - Email clients **block JavaScript** for security reasons - Interactive image carousels/sliders **won't work** - Our solution: Display multiple images in a **static grid layout** - This works in **all email clients** and looks professional - Animated GIFs work, but sliders requiring user interaction don't ### How are images stored? - Images are uploaded to `uploads/products/` directory on your server - Each image gets a unique filename based on product name + timestamp - Full URLs are automatically generated for email embedding - Images are served directly from your server when emails are viewed ## 📊 Campaign Monitoring The script provides real-time feedback: ``` === Starting Bulk Email Campaign === Total recipients: 100 Batch size: 50 ✓ Email sent to: John Doe (john@example.com) ✓ Email sent to: Jane Smith (jane@example.com) ... === Campaign Summary === Successfully sent: 98 Failed: 2 ``` ## 🐛 Troubleshooting **Problem**: "SMTP connection failed" - **Solution**: Check SMTP credentials and port settings **Problem**: Emails going to spam - **Solution**: - Use a verified domain - Add SPF and DKIM records - Avoid spam trigger words - Test with small batches first **Problem**: "Class 'PHPMailer' not found" - **Solution**: Run `composer install` or `composer require phpmailer/phpmailer` ## 📝 Customization ### Change Template Colors Edit `templates/email_template.php`: - Background: `background-color: #ffffff;` - Button: `background-color: #4CAF50;` (change to your brand color) - Text: Modify color values in style attributes ### Add More Product Images Add more image elements in the product section: ```php Product 2 ``` ## 📄 License This project is open-source and available for personal and commercial use. ## 🤝 Support For issues or questions: - Check the troubleshooting section - Review PHPMailer documentation: https://github.com/PHPMailer/PHPMailer - Verify SMTP provider requirements --- **Created for SaroGenix** | Happy Emailing! 📧