Mailgun api响应验证邮件

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;

1个回答

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'];
  ]
);
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐