Skip to content

Commit

Permalink
Temporarily use curl directly to get a working prototype.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuswilms committed Sep 30, 2013
1 parent a79a79a commit d136a17
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions net/mail/transport/adapter/Mailgun.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ class Mailgun extends \li3_mailer\net\mail\transport\adapter\Simple {
'tracking', 'tracking-clicks', 'tracking-opens'
);

/**
* Classes used by `Mailgun`.
*
* @var array
*/
protected $_classes = array('curl' => 'lithium\net\socket\Curl');

/**
* Deliver a message with Mailgun's HTTP REST API via curl.
*
Expand All @@ -67,19 +60,22 @@ class Mailgun extends \li3_mailer\net\mail\transport\adapter\Simple {
public function deliver($message, array $options = array()) {
list($url, $auth, $parameters) = $this->_parameters($message, $options);

$curl = new $this->_classes['curl']();
$curl->open();

$curl->set(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$curl->set(CURLOPT_USERPWD, "{$auth['username']}:{$auth['password']}");
$curl->set(CURLOPT_RETURNTRANSFER, 1);
$curl = curl_init($url);

$curl->set(CURLOPT_CUSTOMREQUEST, 'POST');
$curl->set(CURLOPT_URL, $url);
$curl->set(CURLOPT_POSTFIELDS, $parameters);
curl_setopt_array($curl, array(
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => "{$auth['username']}:{$auth['password']}",
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $parameters
));
$result = curl_exec($curl);

$result = $curl->read();
$curl->close();
$info = curl_getinfo($curl);
if ($info['http_code'] != '200') {
$result = false;
}
curl_close($curl);

return $result;
}
Expand Down

0 comments on commit d136a17

Please sign in to comment.