2016-03-01 269 views
1

我正在使用PHP通过Amazon SES发送电子邮件。为了发送大约1000封个性化的电子邮件,我重复地调用API。但是,在每25次调用API之后,我收到以下错误:亚马逊SES在25个API调用后失败

Fatal error: Uncaught exception 'Aws\Ses\Exception\SesException' with message 'Error executing "SendEmail" on "https://email.eu-west-1.amazonaws.com"; AWS HTTP error: cURL error 77: error setting certificate verify locations: CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 77: error setting certificate verify locations: CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in phar:///home/robcowen/public_html/scripts/aws.phar/GuzzleHttp/Handler/CurlFactory.php:187 Stack trace: #0 phar:///home/robcowen/public_html/scripts/aws.phar/GuzzleHttp/Handler/CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 phar:///home/robcowen/public_html/scripts/aws.phar/GuzzleHttp/Handler/CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handl in phar:///home/robcowen/public_html/scripts/aws.phar/Aws/WrappedHttpHandler.php on line 159 

我在文档中找不到任何引用限制。我试图通过每次20个API调用之后的睡眠(30)或每次调用后的睡眠(1)来延迟我的循环。两者都不起作用。

请问有人有什么想法吗?

+0

Curl抱怨ssl证书,也许你没有正确地提出你的要求? –

+1

SES在[发送率]方面有限制(http://docs.aws.amazon.com/ses/latest/DeveloperGuide/manage-sending-limits.html)。另外,请确保您的帐户不处于沙盒模式。 – Nicolas

+0

我不在沙盒模式。我的极限是: 发送配额:\t发送每24小时 使用的配额50000个电子邮件:\t 0%为2016年3月1日20:23 UTC 最大的发送速率:\t 14电子邮件/秒 – Rob

回答

0

在我遇到这样的错误时,它发生在有多个请求通过套接字读取文件时,所以在循环过程中的某个点它找不到证书并创建一个错误。

解决这个问题的一个不好的方法是在每次调用之前添加sleep(1),给它时间在每个请求上加载证书。

解决它的一个更好的方法是将1000个用户的json列表发送到API或使用邮件列表(我在其他提供者上做过,但不是SES)。一个请求,1000个用户,两台机器在交互中效率更高,并且CPU更友好。