Skip to content

Instantly share code, notes, and snippets.

@ademers
Last active March 29, 2023 10:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ademers/c4b34d090e3ccbc3ba145d824bc97ed1 to your computer and use it in GitHub Desktop.
Save ademers/c4b34d090e3ccbc3ba145d824bc97ed1 to your computer and use it in GitHub Desktop.
Craft CMS Postmark Mailer Component
<?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