-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.2] Allowing passing along transmission options to SparkPost #14166
[5.2] Allowing passing along transmission options to SparkPost #14166
Conversation
@djtarazona this rocks! Only a laravel documentation update at the Sparkpost driver section now required. Will save lots of people lots of problems. |
How do I set this at runtime when queueing messages? |
@kJamesy setting the options at runtime isn't easy as they can only be set when |
Much obliged. |
Unfortunately I don't think I believe you'll have to set the options on the SparkPost transport before you attempt to send the email. // Set SparkPost transport options before sending email
app('swift.transport')->driver('sparkpost')->setOptions([
'open_tracking' => false,
'click_tracking' => false,
'transactional' => true,
]);
// Send email
Mail::to($request->user())->send(new OrderShipped($order)); If you use the mailer's Does that help? Being able to set the transport options on the |
Yeah, makes sense. Many thanks |
Hi, I have a question regarding the options in services.php. I have set up the options as suggested above:
but still links get replaced by sparkpost (http://go.sparkpostmail1.com.....) Any suggestions? Does anything else need to be configured? Using laravel 5.4.11, sparkpost free account PS: also the laravel docs do not mention these options |
@wgmv I dug into the SparkPostTransport class history and found that @taylorotwell removed this feature at this commit 5dace8f#diff-a92e9ec1ecc36811d8edb01394beb2f6 I am still able to set SparkPost options at run time like so: app('swift.transport')->driver('sparkpost')->setOptions([
'open_tracking' => false,
'click_tracking' => false,
'transactional' => true,
]); Update: My bad, Taylor didn't remove the feature, the behaviour is just different, starting from 5.4.0 we need to wrap the config into an additional "options" array like so: 'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
'options' => [
'options' => [
'open_tracking' => false,
'click_tracking' => false,
'transactional' => true,
]
],
], |
Yes, I think we noticed this in another issue/thread. I consider it a bug and am hoping we can get it fixed. Anyone willing to open a PR? Or maybe @taylorotwell can quick fix? |
I wouldn't call it a bug, it's more a small breaking change between 5.3 and 5.4. Actually it's not bad as it is because that allows us to also specify additional options that are outside of the "options" array, like so: 'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
'options' => [
'options' => [
'open_tracking' => false,
'click_tracking' => false,
'transactional' => true,
],
'return_path' => 'bounce@mydomain.com',
'metadata' => [
'foo' => 'bar',
],
],
], Personally I'm happy I can specify return_path (improves deliverability). Some developers may be happy to pass metadata too. What's lacking is proper documentation. And maybe the top level "options" array should be renamed to avoid confusion with the SparkPost options array. |
Got it. Ya better documentation and/or renaming the |
This PR allows specifying an
options
array in Laravel'sservices.php
to be included in the transmission API request.This is useful for enabling / disabling SparkPost features such as open and click tracking. SparkPost defaults to modifying URLs for click tracking. In my particular Laravel project, we only send transactional emails and would rather not have SparkPost change our links for click tracking. Unfortunately, the only way to disable this functionality (without using SparkPost templates) is to include
click_tracking: false
in theoptions
JSON attribute for the transmission API request.Being able to set other options such as marking an email as transactional may be useful to developers as well. Right now, developers would have to extend / override
SparkPostTransport
for this functionality.