定制 phpnomad/php-mail-integration 二次开发

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

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

phpnomad/php-mail-integration

最新稳定版本:1.0.0

Composer 安装命令:

composer require phpnomad/php-mail-integration

包简介

README 文档

README

Latest Version Total Downloads PHP Version License

Integrates PHP's built-in mail() function with phpnomad/email's EmailStrategy. Reach for this when the host already has a working mail transport configured at the PHP level and your application just needs something to drop into the EmailStrategy slot. There are no external library dependencies, no queuing, and no template rendering. The package is a thin adapter between the EmailStrategy contract and the mail() call.

Installation

composer require phpnomad/php-mail-integration

What This Provides

  • PHPMailStrategy implements PHPNomad\Email\Interfaces\EmailStrategy. It joins recipients into a comma-separated list, flattens headers into Key: Value lines, and hands the message to PHP's mail(). A false return from mail() raises EmailSendFailedException.

Requirements

  • phpnomad/email ^1.0
  • A working PHP mail() configuration on the host (sendmail binary, SMTP relay, or the equivalent). The mail() function returns false when the transport is missing or misconfigured, and this strategy converts that into an EmailSendFailedException.

Usage

Bind PHPMailStrategy to EmailStrategy inside an initializer so the container hands it to anything that depends on email sending.

<?php

namespace MyApp\Initializers;

use PHPNomad\Email\Interfaces\EmailStrategy;
use PHPNomad\Loader\Interfaces\HasClassDefinitions;
use PHPNomad\Mail\Integration\Strategies\PHPMailStrategy;

class EmailInitializer implements HasClassDefinitions
{
    public function getClassDefinitions(): array
    {
        return [
            PHPMailStrategy::class => EmailStrategy::class,
        ];
    }
}

Register the initializer in your bootstrapper and any service that type-hints EmailStrategy will receive a PHPMailStrategy instance.

Documentation

PHPNomad bootstrapping and initializers are documented at phpnomad.com. The underlying function is documented in the PHP manual at php.net/manual/en/function.mail.php.

License

MIT. See LICENSE.txt.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-18