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

[5.6] Allow user-defined Sparkpost endpoint #23910

Merged
merged 1 commit into from
Apr 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Illuminate/Mail/Transport/SparkPostTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul

$message->setBcc([]);

$response = $this->client->post('https://api.sparkpost.com/api/v1/transmissions', [
$endpoint = $this->getOptions()['endpoint'] ?? 'https://api.sparkpost.com/api/v1/transmissions';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you think it would be a breaking change if endpoint is not set in service config? https://github.com/laravel/laravel/blob/master/config/services.php#L29

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"??" does an "isset" behind the scenes. If so, there should be no issue.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did forget about that detail on my first attempt at solving this, but this approach should prevent any errors from undefined configurations.
If someone were to backport this to an older version of laravel that doesn't require PHP 7, they'd need to manually check the options. Here's a little 3v4l snippet: https://3v4l.org/No8Mm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it should be set in service config just for the sake of making it obvious that it's customizable (which would mean moving the default endpoint from the transport class to the config array). It would save time for some developers.


$response = $this->client->post($endpoint, [
'headers' => [
'Authorization' => $this->key,
],
Expand Down