phpnomad / php-mail-integration
Requires
- phpnomad/email: ^1.0
Requires (Dev)
- phpnomad/tests: ^0.1.0
This package is auto-updated.
Last update: 2026-04-15 11:08:06 UTC
README
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
PHPMailStrategyimplementsPHPNomad\Email\Interfaces\EmailStrategy. It joins recipients into a comma-separated list, flattens headers intoKey: Valuelines, and hands the message to PHP'smail(). Afalsereturn frommail()raisesEmailSendFailedException.
Requirements
phpnomad/email ^1.0- A working PHP
mail()configuration on the host (sendmail binary, SMTP relay, or the equivalent). Themail()function returnsfalsewhen the transport is missing or misconfigured, and this strategy converts that into anEmailSendFailedException.
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.