Skip to content

Commit 435838e

Browse files
author
s-ichikawa
committed
support Laravel9
1 parent 80a89b2 commit 435838e

File tree

5 files changed

+294
-418
lines changed

5 files changed

+294
-418
lines changed

composer.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"keywords": ["laravel", "sendgrid"],
55
"license": "MIT",
66
"require": {
7-
"illuminate/mail": ">=7.0",
8-
"illuminate/support": ">=7.0",
9-
"guzzlehttp/guzzle": "^6.3 || ^7.0"
7+
"illuminate/mail": "^9.0",
8+
"illuminate/support": "^9.0",
9+
"guzzlehttp/guzzle": "^7.2"
1010
},
1111
"require-dev": {
12-
"illuminate/container": ">=7.0",
13-
"illuminate/filesystem": ">=7.0",
14-
"phpunit/phpunit": "^8.5",
12+
"illuminate/container": "^9.0",
13+
"illuminate/filesystem": "^9.0",
14+
"phpunit/phpunit": "^9.5.8",
1515
"laravel/helpers": "^1.2",
16-
"vlucas/phpdotenv": "^4.1 || ^5.2"
16+
"vlucas/phpdotenv": "^5.4.1"
1717
},
1818
"autoload": {
1919
"psr-4": {
@@ -43,5 +43,7 @@
4343
"Sichikawa\\LaravelSendgridDriver\\SendgridTransportServiceProvider"
4444
]
4545
}
46-
}
46+
},
47+
"minimum-stability": "dev",
48+
"prefer-stable": true
4749
}

src/SendGrid.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
namespace Sichikawa\LaravelSendgridDriver;
44

55
use Illuminate\Mail\Mailable;
6-
use Illuminate\Notifications\Messages\MailMessage;
76
use Sichikawa\LaravelSendgridDriver\Transport\SendgridTransport;
8-
use Swift_Message;
7+
use Symfony\Component\Mime\Email;
98

109
trait SendGrid
1110
{
@@ -16,9 +15,9 @@ trait SendGrid
1615
*/
1716
public function sendgrid($params)
1817
{
19-
if (($this instanceof Mailable || $this instanceof MailMessage) && $this->mailDriver() == "sendgrid") {
20-
$this->withSwiftMessage(function (Swift_Message $message) use ($params) {
21-
$message->embed(new \Swift_Image(static::sgEncode($params), SendgridTransport::SMTP_API_NAME));
18+
if (($this instanceof Mailable) && $this->mailDriver() == "sendgrid") {
19+
$this->withSymfonyMessage(function (Email $email) use ($params) {
20+
$email->embed(static::sgEncode($params), SendgridTransport::REQUEST_BODY_PARAMETER);
2221
});
2322
}
2423
return $this;
@@ -51,7 +50,7 @@ public static function sgEncode($params)
5150
public static function sgDecode($strParams)
5251
{
5352
if (!is_string($strParams)) {
54-
return (array) $strParams;
53+
return (array)$strParams;
5554
}
5655
$params = json_decode($strParams, true);
5756
return is_array($params) ? $params : [];

src/SendgridTransportServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class SendgridTransportServiceProvider extends ServiceProvider
1212
{
1313
/**
14-
* Register the Swift Transport instance.
14+
* Register the Sendgrid Transport instance.
1515
*
1616
* @return void
1717
*/
@@ -23,7 +23,7 @@ public function register()
2323
$config = $this->app['config']->get('services.sendgrid', []);
2424
}
2525
$client = new HttpClient(Arr::get($config, 'guzzle', []));
26-
$endpoint = isset($config['endpoint']) ? $config['endpoint'] : null;
26+
$endpoint = $config['endpoint'] ?? null;
2727

2828
return new SendgridTransport($client, $config['api_key'], $endpoint);
2929
});

0 commit comments

Comments
 (0)