@@ -24,36 +24,35 @@ class MandrillTransport extends AbstractTransport {
2424 */
2525 protected $ _config = array ();
2626
27- /**
28- * Recipients list
29- *
30- * @var mixed
31- */
32- protected $ _recipients = array ();
33-
3427 /**
3528 * Sends out email via Mandrill
3629 *
30+ * @param CakeEmail $email
3731 * @return array
3832 */
3933 public function send (CakeEmail $ email ) {
4034
4135 // CakeEmail
4236 $ this ->_cakeEmail = $ email ;
4337
38+ $ from = $ this ->_cakeEmail ->from ();
39+
40+ list ($ fromEmail ) = array_keys ($ from );
41+
42+ $ fromName = $ from [$ fromEmail ];
43+
4444 $ this ->_config = $ this ->_cakeEmail ->config ();
4545
4646 $ this ->_headers = $ this ->_cakeEmail ->getHeaders ();
47- $ this ->_recipients = $ email ->to ();
4847
4948 $ message = array (
5049 'html ' => $ this ->_cakeEmail ->message ('html ' ),
5150 'text ' => $ this ->_cakeEmail ->message ('text ' ),
5251 'subject ' => mb_decode_mimeheader ($ this ->_cakeEmail ->subject ()),
53- 'from_email ' => $ this -> _config [ ' from ' ] ,
54- 'from_name ' => $ this -> _config [ ' fromName ' ] ,
52+ 'from_email ' => $ fromEmail ,
53+ 'from_name ' => $ fromName ,
5554 'to ' => array (),
56- 'headers ' => array ('Reply-To ' => $ this -> _config [ ' from ' ] ),
55+ 'headers ' => array ('Reply-To ' => $ fromEmail ),
5756 'important ' => false ,
5857 'track_opens ' => null ,
5958 'track_clicks ' => null ,
@@ -73,7 +72,7 @@ public function send(CakeEmail $email) {
7372
7473 $ message = array_merge ($ message , $ this ->_headers );
7574
76- foreach ($ this ->_recipients as $ email => $ name ) {
75+ foreach ($ this ->_cakeEmail -> to () as $ email => $ name ) {
7776 $ message ['to ' ][] = array (
7877 'email ' => $ email ,
7978 'name ' => $ name ,
@@ -115,6 +114,13 @@ public function send(CakeEmail $email) {
115114 return $ this ->_exec ($ params );
116115 }
117116
117+ /**
118+ * Sending API request
119+ *
120+ * @param array $params
121+ * @return array
122+ * @throws Exception
123+ */
118124 private function _exec ($ params ) {
119125 $ params ['key ' ] = $ this ->_config ['api_key ' ];
120126 $ params = json_encode ($ params );
0 commit comments