postmark icon indicating copy to clipboard operation
postmark copied to clipboard

Multisite setup

Open green17 opened this issue 2 years ago • 0 comments

We currently have Postmark setup with Craft using environment variables. As we have a two site setup we would like to change the setup so that each site has it's own stream. We have tried a number of things in config/app.php (please see example below) but it doesn't seem to get picked up.

'mailer' => function() {
    // Get the stored email settings
    $settings = craft\helpers\App::mailSettings();

    // Override the transport adapter class
    $settings->transportType = craft\postmark\Adapter::class;

    if (Craft::$app->sites->getCurrentSite()->handle === 'siteTwo') {
        // Override the transport adapter settings
        $settings->transportSettings = [
            'token' => getenv('POSTMARK_SERVER_API_TOKEN'),
            'messageStream' => getenv('POSTMARK_MESSAGE_STREAM_ID_TRANSACTIONAL_SITETWO'),
        ];
        $settings->fromEmail = getenv('EMAIL_SYSTEM_EMAIL_ADDRESS');
        $settings->fromName = getenv('EMAIL_SENDER_NAME'); 
    }

    // Create a Mailer component config with these settings
    $config = craft\helpers\App::mailerConfig($settings);

    // Instantiate and return it
    return Craft::createObject($config);
},

Craft Pro 3.8.13 Postmark 2.1.0

green17 avatar Nov 07 '23 12:11 green17