diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2017-12-13 05:58:40 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2017-12-13 05:58:40 +0000 |
commit | 6eabf1113cb0837b3ee83c058d9d68fca72e1b71 (patch) | |
tree | 5a996a4e262710e261cb9fdfbfbe7192ace32d9e | |
parent | 97a47666f6bf86c7cb9387eec51dae5bc2486010 (diff) | |
download | Post-SMTP-6eabf1113cb0837b3ee83c058d9d68fca72e1b71.zip |
mailgun docs are old - adjust to the new api
-rw-r--r-- | Postman/Postman-Mail/PostmanMailgunMailEngine.php | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Postman/Postman-Mail/PostmanMailgunMailEngine.php b/Postman/Postman-Mail/PostmanMailgunMailEngine.php index 341ea52..360201c 100644 --- a/Postman/Postman-Mail/PostmanMailgunMailEngine.php +++ b/Postman/Postman-Mail/PostmanMailgunMailEngine.php @@ -148,7 +148,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { // add attachments $this->logger->debug( 'Adding attachments' ); - $attachments = $this->addAttachmentsToMail( $message ); + $this->addAttachmentsToMail( $message ); $result = array(); try { @@ -161,10 +161,10 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { $this->logger->debug( 'Sending mail' ); } - $mgClient = new Mailgun( $this->apiKey ); + $mg = Mailgun::create( $this->apiKey ); // Make the call to the client. - $result = $mgClient->sendMessage( $this->domainName, array_filter( $this->mailgunMessage ), array( 'attachment' => $attachments ) ); + $result = $mg->messages()->send( $this->domainName, array_filter( $this->mailgunMessage ) ); if ( $this->logger->isInfo() ) { $this->logger->info( sprintf( 'Message %d accepted for delivery', PostmanState::getInstance()->getSuccessfulDeliveries() + 1 ) ); @@ -196,7 +196,7 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { $attachments = $message->getAttachments(); if ( ! is_array( $attachments ) ) { // WordPress may a single filename or a newline-delimited string list of multiple filenames - $attArray = explode( PHP_EOL, $attachments ); + $attArray[] = explode( PHP_EOL, $attachments ); } else { $attArray = $attachments; } @@ -205,11 +205,16 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { foreach ( $attArray as $file ) { if ( ! empty( $file ) ) { $this->logger->debug( 'Adding attachment: ' . $file ); - $attachments[] = $file; + $attachments[] = array( 'filePath' => $file ); } } - return $attachments; + if ( ! empty( $attachments ) ) { + if ( $this->logger->isTrace() ) { + $this->logger->trace( $attachments ); + } + $this->mailgunMessage['attachment'] = $attachments; + } } // return the SMTP session transcript |