mailgun-php: localhost development - SSL certificate problem

I’m running my dev site on PHP’s built-in development server (php -S localhost:8000).

The basic code I’m using to send e-mail is as follows:

function email_pdf($pdf, $recipient)
{
    $client = new \Http\Adapter\Guzzle6\Client();
    $mgClient = new Mailgun\Mailgun('my-api-key', $client);

    $result = $mgClient->sendMessage(
        'my-domain',
        [
            'from'    => 'e-mail server <mailgun@my-domain>',
            'to'      => $recipient,
            'subject' => 'subject',
            'html'    => 'html content'
        ],
        [
            'attachment' => [
                // this structure is documented as "backwards compatibility" in code,
                // even though your documentation offers no other way - WTF?
                'filePath' => $pdf,
                'remoteName' => 'bill.pdf',
            ]
    );

    return $result;
}

I’ve downloaded the libraries today, so the versions are mailgun/mailgun-php v2.0, php-http/guzzle6-adapter 1.1.1.

This code throws a Http\Client\Exception\RequestException with the message cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html).

What can be done to make this work?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 27

Most upvoted comments

What about this?

$client = new \GuzzleHttp\Client([
    'verify' => false,
]);
$adapter = new \Http\Adapter\Guzzle6\Client($client);
$mailgun = new \Mailgun\Mailgun($mailgunApiKey, $adapter);

@Nyholm Thanks, that makes sense.

+1 2.0 is currently unusable for me. I’m having the same problem as jurchiks.

I had this problem (not with mailgun though) and it was fixed by amending the php.ini file

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "C:\php\extras\cacert.pem"

and putting the correct cacert.pem in the php/extras folder.