trueapps / boldem-symfony-mailer
Symfony Mailer transport for the Boldem API (boldem.cz).
Package info
github.com/trueapps/boldem-symfony-mailer
Type:symfony-mailer-bridge
pkg:composer/trueapps/boldem-symfony-mailer
Requires
- php: >=8.1
- psr/log: ^1.1 || ^2.0 || ^3.0
- symfony/event-dispatcher-contracts: ^2.5 || ^3.0
- symfony/http-client: ^6.4 || ^7.0
- symfony/http-client-contracts: ^2.5 || ^3.0
- symfony/mailer: ^6.4 || ^7.0
- symfony/mime: ^6.4 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^10.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A Symfony Mailer transport for the Boldem transactional-email API.
The transport authenticates with OAuth client credentials, caches the returned
bearer token for the lifetime of the object, and delivers messages through the
/api/transactionalemails endpoint. Recipient lists larger than batchSize
(default 50) are split across multiple API calls to match the per-request
recipient cap.
Supersedes trueapps/boldem-swiftmailer, which targeted the now-EOL SwiftMailer 6.
Installation
composer require trueapps/boldem-symfony-mailer
Requires PHP 8.1+ and symfony/mailer ^6.4 || ^7.0.
Usage
use Boldem\Transport; use Symfony\Component\Mailer\Mailer; use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Email; $transport = new Transport('<CLIENT_ID>', '<SECRET_CLIENT_KEY>'); $mailer = new Mailer($transport); $email = (new Email()) ->from(new Address('john@example.com', 'John Doe')) ->to('jane@example.com') ->subject('Hello from Boldem!') ->text('Plain-text alternative') ->html('<b>HTML body</b>'); // Optional Boldem tag: $email->getHeaders()->addTextHeader('X-MK-Tag', 'custom-tag'); $mailer->send($email);
Bulk sends
Set $transport->isBulk = true; before sending campaign traffic to have the
API treat the message as bulk.
Custom HTTP client / dispatcher / logger
The constructor optionally accepts a Symfony\Contracts\HttpClient\HttpClientInterface,
a PSR-14 EventDispatcherInterface, and a PSR-3 LoggerInterface, so the
transport plays with the standard Symfony Mailer wiring:
$transport = new Transport( clientId: '<CLIENT_ID>', secretClientKey: '<SECRET_CLIENT_KEY>', defaultHeaders: ['X-MK-Tag' => 'newsletters'], client: $httpClient, dispatcher: $eventDispatcher, logger: $logger, );
Notes
- Boldem re-derives
Subject,Content-Type,MIME-Version,Date,From,To,Cc,Bcc, andReply-Tofrom the payload; those headers are filtered out before the request is sent. X-MK-Tagis mapped to the API'sTagfield.- Non-2xx responses raise
Symfony\Component\Mailer\Exception\HttpTransportException.
License
MIT. See LICENSE.