A lightweight, dependency-free PHP SMTP Mailer with support for:
- 📤 Sending plain text and HTML emails
- 📎 Attachments
- 👁️🗨️ Tracking pixel (read/open tracking)
- ✅ SMTP-level read receipt requests (RCPT NOTIFY)
- 🛡️ TLS / SSL / STARTTLS support
- 🛠️ Fallback to native
mail()on failure - 🐞 Debug mode for troubleshooting
- ✅ Simple API, single class
- 📦 No external dependencies
- 💬 Rich content: Plain text & HTML
- 📎 Attach multiple files
- 🔒 Secure with SSL, TLS, or STARTTLS
- 👁️ Tracking pixel integration with your server
- 📨 Read receipt notification via SMTP
RCPT TO NOTIFY - ⛑️ Fallback to native
mail()if SMTP fails (optional) - 🧪 Debug output for SMTP commands
- ✅ Transactional email sending (invoices, alerts)
- 📢 Email marketing campaigns (with tracking)
- 📩 Application-based notifications
- 🧪 Development/testing mail delivery
- 👁️ Track when an important email is read
Copy the Mailer.php file to your project.
Alternatively, if you're using Composer:
composer require hitraa/openforge-maileropenforge-mailer/
├── src/
│ └── Mailer.php
├── examples/
│ ├── basic-send.php
│ └── track.php
├── composer.json
├── LICENSE
└── README.md
require_once 'vendor/autoload.php';
use OpenForge\Mailer\Mailer;
$mail = new Mailer('smtp.yourhost.com', 'your@email.com', 'password');
$mail->setFrom('Your Name <your@email.com>')
->setRecipient('to@example.com')
->setSubject('Hello!')
->setBody('This is the plain-text version.')
->setHTMLBody('<h1>Hello!</h1><p>This is the HTML version.</p>');
echo $mail->send();$mail->setAttachment('/path/to/file.pdf');$mail->enableTrackingPixel('https://yourdomain.com/track.php');Your endpoint should log or store open events using query params like
?message_id=...&email=...
Enabling read receipts:
$mail->requestReadReceipt(true);This adds NOTIFY=SUCCESS,FAILURE,DELAY in RCPT TO, and the recipient's mail server will notify (if supported).
Also adds optional headers:
Disposition-Notification-ToReturn-Receipt-ToX-Confirm-Reading-To
Note: Behavior depends on recipient's server & client.
$mail->allowFallbackToMail(true);$mail->setMessageIdPrefix('track-');$mail->setRecipient(['one@example.com', 'two@example.com']);Supports:
Name <email@example.com>"Name" <email@example.com>email@example.com
Enable SMTP-level debug messages:
$mail->enableDebug(true);This will print the SMTP command flow.
- 📄
examples/basic-send.php— Full example with HTML, text, attachment. - 📄
examples/track.php— Tracking pixel handler.
| Default port | Option | Description | Mailer constant |
|---|---|---|---|
| 587 | tls |
Default (STARTTLS) | Mailer::SECURE_TLS |
| 465 | ssl |
SSL connection | Mailer::SECURE_SSL |
| 587 | starttls |
Explicit STARTTLS | Mailer::SECURE_STARTTLS |
Released under the MIT License
Made with ❤️ by Harshal Khairnar Founder, Hitraa Technologies 📧 harshal@hitraa.com
Feel free to fork and submit pull requests. All improvements are welcome!
This library is designed for educational and production-ready purposes. Use responsibly when tracking user interactions.