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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器