1 | <?php |
||
10 | class PostmarkTransport extends Transport |
||
11 | { |
||
12 | /** |
||
13 | * Guzzle client instance. |
||
14 | * |
||
15 | * @var \GuzzleHttp\ClientInterface |
||
16 | */ |
||
17 | protected $client; |
||
18 | |||
19 | /** |
||
20 | * The Postmark API key. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $key; |
||
25 | |||
26 | /** |
||
27 | * The Postmark API end-point. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $url = 'https://api.postmarkapp.com/email'; |
||
32 | |||
33 | /** |
||
34 | * Create a new Postmark transport instance. |
||
35 | * |
||
36 | * @param \GuzzleHttp\ClientInterface $client |
||
37 | * @param string $key |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | 5 | public function __construct(ClientInterface $client, $key) |
|
46 | |||
47 | /** |
||
48 | * Send the given Message. |
||
49 | * |
||
50 | * Recipient/sender data will be retrieved from the Message API. |
||
51 | * The return value is the number of recipients who were accepted for delivery. |
||
52 | * |
||
53 | * @param Swift_Mime_Message $message |
||
54 | * @param string[] $failedRecipients An array of failures by-reference |
||
55 | * |
||
56 | * @return int |
||
57 | */ |
||
58 | 1 | public function send(Swift_Mime_Message $message, &$failedRecipients = null) |
|
73 | |||
74 | /** |
||
75 | * Get all attachments for the given message. |
||
76 | * |
||
77 | * @param \Swift_Mime_Message $message |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | 2 | protected function getAttachments(Swift_Mime_Message $message) |
|
101 | |||
102 | /** |
||
103 | * Format the contacts for the API request |
||
104 | * |
||
105 | * @param array $contacts |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | 3 | protected function getContacts($contacts) |
|
118 | |||
119 | /** |
||
120 | * Get the "From" payload field for the API request. |
||
121 | * |
||
122 | * @param \Swift_Mime_Message $message |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | 3 | protected function getFrom(Swift_Mime_Message $message) |
|
135 | |||
136 | /** |
||
137 | * Get the message ID from the response. |
||
138 | * |
||
139 | * @param \GuzzleHttp\Psr7\Response $response |
||
140 | * @return string |
||
141 | */ |
||
142 | 1 | protected function getMessageId($response) |
|
149 | |||
150 | /** |
||
151 | * Get the HTTP payload for sending the Postmark message. |
||
152 | * |
||
153 | * @param \Swift_Mime_Message $message |
||
154 | * |
||
155 | * @return array |
||
156 | */ |
||
157 | 2 | protected function payload(Swift_Mime_Message $message) |
|
185 | } |
||
186 |