1 | <?php |
||
9 | class PostmarkTransport extends Transport |
||
10 | { |
||
11 | /** |
||
12 | * Guzzle client instance. |
||
13 | * |
||
14 | * @var \GuzzleHttp\ClientInterface |
||
15 | */ |
||
16 | protected $client; |
||
17 | |||
18 | /** |
||
19 | * The Postmark API key. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $key; |
||
24 | |||
25 | /** |
||
26 | * The Postmark API end-point. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $url = 'https://api.postmarkapp.com/email'; |
||
31 | |||
32 | /** |
||
33 | * Create a new Postmark transport instance. |
||
34 | * |
||
35 | * @param \GuzzleHttp\ClientInterface $client |
||
36 | * @param string $key |
||
37 | * |
||
38 | * @return void |
||
39 | */ |
||
40 | 5 | public function __construct(ClientInterface $client, $key) |
|
45 | |||
46 | /** |
||
47 | * Send the given Message. |
||
48 | * |
||
49 | * Recipient/sender data will be retrieved from the Message API. |
||
50 | * The return value is the number of recipients who were accepted for delivery. |
||
51 | * |
||
52 | * @param Swift_Mime_Message $message |
||
53 | * @param string[] $failedRecipients An array of failures by-reference |
||
54 | * |
||
55 | * @return int |
||
56 | */ |
||
57 | 1 | public function send(Swift_Mime_Message $message, &$failedRecipients = null) |
|
67 | |||
68 | /** |
||
69 | * Format the contacts for the API request |
||
70 | * |
||
71 | * @param array $contacts |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | 3 | protected function getContacts($contacts) |
|
84 | |||
85 | /** |
||
86 | * Get the "From" payload field for the API request. |
||
87 | * |
||
88 | * @param \Swift_Mime_Message $message |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | 3 | protected function getFrom(Swift_Mime_Message $message) |
|
101 | |||
102 | /** |
||
103 | * Get the HTTP payload for sending the Postmark message. |
||
104 | * |
||
105 | * @param \Swift_Mime_Message $message |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | 2 | protected function payload(Swift_Mime_Message $message) |
|
133 | } |
||
134 |