Skip to content

Commit

Permalink
clean and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightbr committed Jun 20, 2017
1 parent 4ee548c commit 8619e3e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions SwiftMailer/MailjetTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MailjetTransport implements Swift_Transport
* Mailjet client
* @var \Mailjet\Client
*/
protected $mailjetClient;
protected $mailjetClient = null;

/**
* Mailjet API Key
Expand Down Expand Up @@ -72,9 +72,6 @@ public function __construct(Swift_Events_EventDispatcher $eventDispatcher, $apiK
$this->apiSecret = $apiSecret;
$this->call = $call;
$this->clientOptions = $clientOptions;

// create Mailjet client
$this->mailjetClient = $this->createMailjetClient();
}

/**
Expand Down Expand Up @@ -124,8 +121,10 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
// extract Mailjet Message from SwiftMailer Message
$mailjetMessage = $this->getMailjetMessage($message);

dump($this->mailjetClient);

if(is_null($this->mailjetClient)){
// create Mailjet client
$this->mailjetClient = $this->createMailjetClient();
}

try {
// send API call
Expand Down Expand Up @@ -175,6 +174,11 @@ public function bulkSend(array $messages, &$failedRecipients = null)
array_push($bodyRequest['Messages'], $mailjetMessage);
}

if(is_null($this->mailjetClient)){
// create Mailjet client
$this->mailjetClient = $this->createMailjetClient();
}

try {
// send API call
$this->resultApi = $this->mailjetClient->post(Resources::$Email, ['body' => $bodyRequest]);
Expand Down

0 comments on commit 8619e3e

Please sign in to comment.