dosc9472 2019-05-10 21:20
浏览 131

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条回答

  • dsf12123 2019-08-23 16:35
    关注

    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'];
      ]
    );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog