A transactional email sending library using the php-email domain
Courier is a library to send transactional emails using domain objects and concise interfaces.
See full documentation for more details.
Courier provides an interface to sending standardized emails using third-party SaaS SMTP providers, like SparkPost and Postmark. By leveraging a standardized domain model for defining emails, Courier is capable of defining drivers (or "couriers" in our case) that allow the developer to easily switch how the provider sending their emails without changing any part of their code that builds the email.
composer require quartzy/courier
Each email provider will also have their own courier dependency:
# Send emails with Sparkpost composer require quartzy/courier-sparkpost
Now you just need to create an email and send it:
<?php use Courier\Sparkpost\SparkpostCourier; use GuzzleHttp\Client; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; use PhpEmail\EmailBuilder; use PhpEmail\Content\SimpleContent; use SparkPost\SparkPost; $courier = new SparkPostCourier( new SparkPost(new GuzzleAdapter(new Client()), ['key'=>'YOUR_API_KEY']) ); $email = EmailBuilder::email() ->withSubject('Welcome!') ->withContent(SimpleContent::text('Start your free trial now!!!')) ->from('email@example.com') ->to('firstname.lastname@example.org') ->build(); $courier->deliver($email);
For details on building the email objects, see Php Email.
Please see CHANGELOG for more information what has changed recently.
If you discover any security related issues, please email email@example.com instead of using the issue tracker.
The Apache License, v2.0. Please see License File for more information.