定制 hitraa/openforge-mailer 二次开发

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

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

hitraa/openforge-mailer

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.

hitraa/openforge-mailer 适用场景与选型建议

hitraa/openforge-mailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mail」 「mailer」 「php」 「email」 「html」 「smtp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hitraa/openforge-mailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hitraa/openforge-mailer 我们能提供哪些服务?
定制开发 / 二次开发

基于 hitraa/openforge-mailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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