I attempted to set up Postmark on SS 4.2 today. I was able to send email by installing the official Swift Transport for Postmark:
$ composer require wildbit/swiftmailer-postmark ^2
And then using the following configuration:
---
Name: my-email
After:
- '#emailconfig'
---
SilverStripe\Core\Injector\Injector:
Swift_Transport:
class: Postmark\Transport
constructor:
0: '<my-postmark-api-key>'
Big caveat though, the official v2 transport class is missing plugin and event support. This means that environment settings like SS_SEND_ALL_EMAILS_TO
are ignored.
v3 looks better, but requires SwiftMailer v6, and SilverStripe is currently locked to v5. So I forked the repo and cherry picked some commits to make a franken-version compatible with SilverStripe 4.2 that supports the beforeSend event. If you want to use it too, edit your composer.json as such:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/jonom/swiftmailer-postmark"
}
],
"require": {
"wildbit/swiftmailer-postmark": "dev-swift5"
}
Getting this working on SS4 was trickier than I expected so I’m sharing my process in case it helps other Postmark fans
Update: If you need guzzle 7 you can use the swift5-guzzle7 branch. It’s a tiny change and I could probably merge that in to the swift-5 branch but I like to play it safe.