Last active
March 29, 2023 10:51
-
-
Save ademers/c4b34d090e3ccbc3ba145d824bc97ed1 to your computer and use it in GitHub Desktop.
Craft CMS Postmark Mailer Component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'components' => [ | |
'mailer' => function() { | |
// Get the stored email settings | |
$settings = craft\helpers\App::mailSettings(); | |
// Override the transport adapter class | |
$settings->transportType = craft\postmark\Adapter::class; | |
// Override the transport adapter settings | |
$settings->transportSettings = [ | |
'token' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | |
// Using env vars | |
// 'token' => getenv('POSTMARK_SERVER_TOKEN'), | |
]; | |
// Create a Mailer component config with these settings | |
$config = craft\helpers\App::mailerConfig($settings); | |
// Instantiate and return it | |
return Craft::createObject($config); | |
}, | |
], | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment