定制 hitraa/openforge-mailer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hitraa/openforge-mailer

最新稳定版本:v1.0.0

Composer 安装命令:

composer require hitraa/openforge-mailer

包简介

Lightweight PHP SMTP Mailer with HTML, attachments, tracking pixel, and read receipt support.

README 文档

README

Latest Version License PHP Version

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

🚀 Features

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

📘 Example Use Cases

  • ✅ Transactional email sending (invoices, alerts)
  • 📢 Email marketing campaigns (with tracking)
  • 📩 Application-based notifications
  • 🧪 Development/testing mail delivery
  • 👁️ Track when an important email is read

📦 Installation

Copy the Mailer.php file to your project.

Alternatively, if you're using Composer:

composer require hitraa/openforge-mailer

📁 Directory Structure

openforge-mailer/
├── src/
│   └── Mailer.php
├── examples/
│   ├── basic-send.php
│   └── track.php
├── composer.json
├── LICENSE
└── README.md

🚀 Usage

1. Basic email

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();

2. With attachments

$mail->setAttachment('/path/to/file.pdf');

3. With tracking pixel

$mail->enableTrackingPixel('https://yourdomain.com/track.php');

Your endpoint should log or store open events using query params like ?message_id=...&email=...

4. SMTP read receipt (SMTP DSN) behavior

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-To
  • Return-Receipt-To
  • X-Confirm-Reading-To

Note: Behavior depends on recipient's server & client.

5. Fallback to PHP mail() if SMTP fails

$mail->allowFallbackToMail(true);

6. With custom message id prefix

$mail->setMessageIdPrefix('track-');

7. With multiple recipients

$mail->setRecipient(['one@example.com', 'two@example.com']);

Parse RFC email formats

Supports:

  • Name <email@example.com>
  • "Name" <email@example.com>
  • email@example.com

🐞 Debugging

Enable SMTP-level debug messages:

$mail->enableDebug(true);

This will print the SMTP command flow.

📂 Example File

🔐 SMTP Security Options

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

🛡 License

Released under the MIT License

👨‍💻 Author

Made with ❤️ by Harshal Khairnar Founder, Hitraa Technologies 📧 harshal@hitraa.com

🤝 Contributions

Feel free to fork and submit pull requests. All improvements are welcome!

⚠️ Disclaimer

This library is designed for educational and production-ready purposes. Use responsibly when tracking user interactions.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-15