spatie / mailcoach-support

Questions and support for Mailcoach
https://mailcoach.app
31 stars 2 forks source link

Postmark Broadcast Support #270

Closed beberlei closed 3 years ago

beberlei commented 3 years ago

Follow up to #188

The Postmark adapter for Mailcoach needs support for Broadcast Streams. This is necessary to move from transactional sending mode to broadcast sending mode. This was added in https://github.com/wildbit/swiftmailer-postmark/pull/35 and released in wildbit/swiftmailer-postmark 3.3 which Mailcoach v3 uses.

Laravel's MailManager::createPostmarkTransport does not support this option yet though, can it be overwritten?

In addition the Mailcoach Postmark Configuration form needs to optionally set this in PostmarkConfigurationDriver.

freekmurze commented 3 years ago

If you need this quick, we'd accept a PR that adds support for Broadcast streams to the Postmark adapter package. Otherwise we'll take a look in the next couple of weeks.

beberlei commented 3 years ago

I am using the following workaround for now using a MessageSending listener:

// app/Listeners/PostmarkMessageStream.php
<?php

namespace App\Listeners;

use Illuminate\Mail\Events\MessageSending;

class PostmarkMessageStream
{
    public function handle(MessageSending $mailEvent)
    {
        $message = $mailEvent->message;
        $message->getHeaders()->addTextHeader('X-PM-Message-Stream', 'newsletters');
    }
}

And i updated the EventServiceProvider:

<?php

namespace App\Providers;

use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Mail\Events\MessageSending;
use Illuminate\Support\Facades\Event;

use App\Listeners\PostmarkMessageStream;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        MessageSending::class => [
            PostmarkMessageStream::class,
        ],
    ];
    // ...
}
riasvdv commented 3 years ago

This is now available with the following versions:

laravel-mailcoach-postmark-feedback: 2.4.1 mailcoach-ui: 1.1.0

Let me know if everything works as expected!