putyourlightson / craft-campaign

Send and manage email campaigns, contacts and mailing lists in Craft CMS.
https://putyourlightson.com/plugins/campaign
Other
64 stars 24 forks source link

Change `messageStream` value depending on Campaign field #453

Closed Saboteur777 closed 7 months ago

Saboteur777 commented 7 months ago

I use Postmark to send out Broadcast and Transactional e-mail from my app. Broadcast messages are sent from Campaign, with the following campaign.php configuration:

    return [
        'production' => [
            'transportType' => \craftcms\postmark\Adapter::class,
            'transportSettings' => [
                'token' => getenv('POSTMARK_SERVER_TOKEN'),
                'messageStream' => getenv('POSTMARK_BROADCAST_STREAM_ID')
            ]
        ],
    ]

I would like to change messageStream dynamically, based on the value of a field in the Campaign being currently sent.

Use case

I have to send e-mails where subscriptions should not be possible. Postmark Support suggested to use a separate message stream to these messages. Whenever a user unsubscribes from this stream, they should be added back to it programmatically: listening to the Subscription change webhook, and deleting the Suppression could solve my issue.

This issue is also loosely related to #286 , #304 , and #331 .

Question:

Is it possible to set messageStream programmatically?

bencroker commented 7 months ago

That might be possible, but I don’t see why it would be necessary. The docs recommend ensuring that the Postmark unsubscribe link is removed, which means that contacts will only be able to unsubscribe from mailing lists via Campaign. You can then decide which campaign types include an unsubscribe link and which don’t. Does that make sense and does it resolve your issue?

Saboteur777 commented 7 months ago

You are right, I asked them to remove the unsubscribe link from messages sent through that Stream. Thank you!