Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multiple postmark drivers with stream ID in Laravel application #40

Open
christophrumpel opened this issue Dec 29, 2020 · 7 comments

Comments

@christophrumpel
Copy link

I'm using a newsletter application (Mailcoach) where you can define two different mail drivers:

  • one for bulk emails
  • one for transx emails

Postmark also suggests sending through different streams.

This package lets you define the "Postmark Message Stream" by adding the stream id to the header. But when you use the postmark driver in Laravel, you only have the option to define the token seen here: https://github.com/laravel/framework/blob/bd67cc22af6fbc1f5745b0e3ce79e0a12b092048/src/Illuminate/Mail/MailManager.php#L325

So even if I create two postmark mail drivers, I could only use a different API token (= 2 different Postmark "servers"), but I cannot define the message stream.

If the above assumptions are correct, I could do a PR on Laravel to also get a headers array from the services.php config file. What do you think?

@christophrumpel
Copy link
Author

One Addition: I know you can change the mail's header on a per mailable basis. https://laravel.com/docs/8.x/mail#customizing-the-swiftmailer-message

But since Postmark's stream, are almost like a different account, it would behandy to define the stream also on a driver-level.

@christophrumpel christophrumpel changed the title Use multiple postmark drivers in Laravel application Use multiple postmark drivers with stream ID in Laravel application Dec 29, 2020
@christophrumpel
Copy link
Author

I already created a PR on Laravel. Let's see if it gets merged: laravel/framework#35755

@oxodesign
Copy link

@christophrumpel is this working for you? Im running Laravel 8.32.1 and Im trying to send to different stream without any luck.

this is my configuration:

'mailers' => [
        'pm-custom' => [
            'transport' => 'postmark',
            'message_stream_id' => 'custom-stream-id',
        ],
    ],

Trying to test like this:

Mail::mailer('pm-custom')
            ->to('name@example.com')
            ->send(new TestMailable());
            

I also tried to add mailer to the Mailable without any luck, all test emails went to default stream.

All help appreciated

@christophrumpel
Copy link
Author

Hey, it is working for but I only tested by using my newsletter software Mailcoach where I can select different mailers.

Here is my config https://github.com/christophrumpel/christoph-rumpel.com/blob/production/config/mail.php#L61-L83
Have you set a token somewhere else?

@oxodesign
Copy link

Hmmm. yes under services, but that is what is suggested by the docs. I see you dont have that in your config! Will test by removing it and report back. Thanks for your help

@lightwalkernet
Copy link

@oxodesign did you get this to work with changing the mailer?
For me it continues to send from the default postmark account even if I remove the token from services config which is very strange. Would be grateful for some guidance.

@oxodesign
Copy link

@oxodesign did you get this to work with changing the mailer? For me it continues to send from the default postmark account even if I remove the token from services config which is very strange. Would be grateful for some guidance.

No, sorry for late reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants