定制 byjg/mailwrapper 二次开发

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

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

byjg/mailwrapper

最新稳定版本:6.0.0

Composer 安装命令:

composer require byjg/mailwrapper

包简介

A lightweight wrapper for sending email. The interface is totally decoupled from the sender, providing a single interface for sending mail regardless of the underlying mail service.

README 文档

README

Sponsor Build Status Opensource ByJG GitHub source GitHub license GitHub release

A lightweight wrapper for sending email. The interface is totally decoupled from the sender, providing a single interface for sending mail regardless of the underlying mail service.

Available Wrappers

  • SMTP - SMTP with SSL/TLS support
  • AWS SES - Amazon Simple Email Service (using API directly)
  • Mailgun - Mailgun API (using API directly)
  • SendMail - PHP's built-in mail() function
  • FakeSender - For testing (does nothing)

Install

composer require "byjg/mailwrapper"

Documentation

Quick Start

<?php require "vendor/autoload.php"; // Create the email envelope $envelope = new \ByJG\Mail\Envelope(); $envelope->setFrom('johndoe@example.com', 'John Doe'); $envelope->addTo('jane@example.com'); $envelope->setSubject('Email Subject'); $envelope->setBody('<h1>Hello World</h1>'); // Register available mailers \ByJG\Mail\MailerFactory::registerMailer(\ByJG\Mail\Wrapper\PHPMailerWrapper::class); \ByJG\Mail\MailerFactory::registerMailer(\ByJG\Mail\Wrapper\MailgunApiWrapper::class); // Create mailer from connection string $mailer = \ByJG\Mail\MailerFactory::create('smtp://username:password@smtp.example.com:587'); // Send the email $result = $mailer->send($envelope);

Architecture

MailWrapper is organized into three main components:

  • The Envelope: The mail message. Defines the sender, recipients, body, subject, attachments, etc.
  • The Mailer: Responsible for the process of sending the envelope
  • The Factory: Registers and creates the available Mailers in the system

Connection URL Schemes

Scheme Description URI Pattern
smtp SMTP over insecure connection smtp://username:password@host:25
tls SMTP over secure TLS connection tls://username:password@host:587
ssl SMTP over secure SSL connection ssl://username:password@host:465
sendmail PHP's built-in mail() function sendmail://localhost
mailgun Mailgun API mailgun://YOUR_API_KEY@YOUR_DOMAIN
ses Amazon SES API ses://ACCESS_KEY_ID:SECRET_KEY@REGION
fakesender Testing (does nothing) fakesender://localhost

See Connection Strings for detailed configuration examples.

Running Tests

./vendor/bin/phpunit

Dependencies

flowchart TD byjg/mailwrapper --> byjg/convert byjg/mailwrapper --> byjg/webrequest 
Loading

Open source ByJG

统计信息

  • 总下载量: 49.64k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 2
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固