I have been using the mail API to validate emails, but it has not returned the response. I am doing something wrong?
curl_setopt_array($this->curl, array(
CURLOPT_URL => "https://api.mailgun.net/v4/address/validate?address=".$email,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "address=".$email,
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
"Authorization: Basic " . base64_encode("api:mikey")
),
));
$result=curl_exec ($this->curl);
error_log("result ". print_r($result, true));
$err = curl_error($this->curl);
curl_close($this->curl);
error_log("url: ".print_r($url, true));
error_log("error: ".print_r($err, true));
error_log("result: ".print_r($result, true));
return $result;
Well, I faced this same problem but using Guzzle 6.
You should put your account domain at the end of the API Base URL:
https://api.mailgun.net/v4/mysite.com
In Guzzle, these are my configurations (scripts in PHP):
$http_client = new Client([
'base_uri' => 'https://api.mailgun.net/v4/mysite.com',
'allow_redirects' => true,
'debug' => true, // for development purposes
'http_errors' => false
]);
This is the GET Request call:
$response = $http_client->request(
'get',
'address/validate',
[
'query' => ['address' => 'mail@mail.com']
'auth' => ['api', 'your_account_api_private_key'];
]
);