drtkyykai004574380
2018-02-19 11:48
浏览 195
已采纳

如何使用PHP通过ZOHO api发送电子邮件?

I've followed this doc and here is my code:

$url = "https://mail.zoho.com/api/accounts/662704xxx/messages";
$param = [  "fromAddress"=> "myemail@mydomain.com",
            "toAddress"=> "somewhere@gmail.com",
            "ccAddress"=> "",
            "bccAddress"=> "",
            "subject"=> "Email - Always and Forever",
            "content"=> "Email can never be dead ..."];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
die;

And the response is:

{"data":{"errorCode":"INVALID_TICKET","moreInfo":"Invalid ticket"},"status":{"code":400,"description":"Invalid Input"}}

And the response means: (according to this)

BAD REQUEST - The input passed in the Request API is invalid or incorrect. The requestor has to change the input parameters and send the Request again.

Any idea how can I fix it?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题