|
3 | 3 | namespace ExpertCoder\Swiftmailer\SendGridBundle\Services; |
4 | 4 |
|
5 | 5 | use finfo; |
| 6 | +use Psr\Log\LoggerInterface; |
6 | 7 | use SendGrid; |
| 8 | +use Swift_Events_EventDispatcher; |
7 | 9 | use Swift_Events_EventListener; |
| 10 | +use Swift_Events_SendEvent; |
8 | 11 | use Swift_Mime_Attachment; |
9 | 12 | use Swift_Mime_SimpleMessage; |
10 | 13 | use Swift_Transport; |
11 | | -use Swift_Events_EventDispatcher; |
12 | | -use Swift_Events_SendEvent; |
13 | | -use Psr\Log\LoggerInterface; |
14 | 14 |
|
15 | 15 | class SendGridTransport implements Swift_Transport |
16 | 16 | { |
@@ -70,11 +70,22 @@ class SendGridTransport implements Swift_Transport |
70 | 70 |
|
71 | 71 | /** |
72 | 72 | * Some header keys are reserved. You may not include any of the following reserved keys |
73 | | - * (From SendGrid docs) |
| 73 | + * |
| 74 | + * @see https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#-Headers-Errors |
74 | 75 | */ |
75 | 76 | const RESERVED_KEYWORDS = [ |
76 | | - 'X-SG-ID', 'X-SG-EID', 'RECEIVED', 'DKIM-SIGNATURE', 'CONTENT-TYPE', 'CONTENT-TRANSFER-ENCODING', |
77 | | - 'TO', 'FROM', 'SUBJECT', 'REPLY-TO', 'CC', 'BCC' |
| 77 | + 'X-SG-ID', |
| 78 | + 'X-SG-EID', |
| 79 | + 'RECEIVED', |
| 80 | + 'DKIM-SIGNATURE', |
| 81 | + 'CONTENT-TYPE', |
| 82 | + 'CONTENT-TRANSFER-ENCODING', |
| 83 | + 'TO', |
| 84 | + 'FROM', |
| 85 | + 'SUBJECT', |
| 86 | + 'REPLY-TO', |
| 87 | + 'CC', |
| 88 | + 'BCC', |
78 | 89 | ]; |
79 | 90 |
|
80 | 91 | public function __construct(Swift_Events_EventDispatcher $eventDispatcher, $sendGridApiKey, $sendGridCategories) |
@@ -260,7 +271,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul |
260 | 271 | } |
261 | 272 |
|
262 | 273 | if ($evt) { |
263 | | - if ($sent == count($toArr) + count($ccArr) + count($bccArr)) { |
| 274 | + if ($sent == count($toArr ?? []) + count($ccArr ?? []) + count($bccArr ?? [])) { |
264 | 275 | $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); |
265 | 276 | } elseif ($sent > 0) { |
266 | 277 | $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE); |
|
0 commit comments