Closed joshuabaker closed 6 years ago
Correct. Currently, the only way to set the token is via the admin panel. My assumption is you have alternate postmark instances and you want to tie them to an environment?
Yeah, that’s right.
I was trying to figure out how to do this via the Mailer Component config. Wondering if that’s an approach here?
I was just drilling into the System Settings and saw that option too.
I'm sure something like this might work (config/app.php
):
<?php
return [
'*' => [
'components' => [
'mailer' => function() {
// Get the stored email settings
$settings = Craft::$app->systemSettings->getEmailSettings();
// Override the transport adapter class
$settings->transportSettings['token'] = 'xxx';
return Craft::createObject(
craft\helpers\App::mailerConfig($settings)
);
}
]
],
'prod' => [
'components' => [
'mailer' => function() {
// Get the stored email settings
$settings = Craft::$app->systemSettings->getEmailSettings();
// Override the transport adapter class
$settings->transportSettings['token'] = 'prod-xxx';
return Craft::createObject(
craft\helpers\App::mailerConfig($settings)
);
}
]
]
];
It's not very graceful.
I suppose it's also possible to add a settings model to the plugin and override what's in the database when the Postmark adapter is created.
I don't really like the component config solution, because it implies that you'll always use Postmark.
Yeah, I agree. As much as I hate the component config approach, it’s not really for this plugin to address.
Thanks for the responses, dude. 👍
Hey Josh,
Check out the latest release 1.0.0 (https://github.com/flipboxfactory/craft-postmark/releases/tag/1.0.0)
You can now set the token via config/postmark.php
Love it! Thanks, Nate. 💯
It doesn’t appear possible to set the token value via a
postmark.php
config file. Attempting currently results in an error.Config
Error