【发布时间】:2018-03-21 00:59:08
【问题描述】:
我正在尝试使用 ZohoMail 的 API 通过我的应用程序发送电子邮件。但它一直在给我:
"{errorCode":"INVALID_METHOD"},"status":{"code":404,"description":"无效输入"}}
这是我正在尝试拨打的电话的链接:https://www.zoho.com/mail/help/api/post-send-an-email.html#Request_Body
这是我的功能:
public static function sendEmail ($AccountId, $AuthCode, $FromAddress, $ToAddress, $Subject, $Content){
$client = new Client(); //GuzzleHttp\Client
$URI = 'http://mail.zoho.com/api/accounts/' . $AccountId . '/messages';
$headers = ['Content-Type' => 'application/json', 'Authorization' => 'Zoho-authtoken ' . $AuthCode];
$body = array('fromAddress' => $FromAddress, 'toAddress' => $ToAddress, 'subject' => $Subject, 'content' => $Content);
$Nbody = json_encode($body);
$response = $client->post($URI, $headers, $Nbody);
echo "DONE!";
}
我尝试过改变拨打电话的方式,但似乎不是问题所在。我已经在 PostMan 中测试了通话,它工作正常,所以我拨打电话的方式可能有问题。任何帮助将不胜感激。
【问题讨论】: