我最近遇到了电子邮件问题,一周前开始在发送电子邮件时出现错误,问题是有时调用此函数sendEmail
时,它永远不会返回Aws/Result
或任何{ {1}}。所以我的脚本被循环等待。这个问题是零星的。我想我的请求无法添加到AWS队列中,但至少会得到一个异常。
我试图找到一个可以永久设置为不等待的超时设置,但是我在文档中找不到它。我使用这项服务已有2年了,直到现在我都没有收到错误消息。
有人遇到了这个问题吗?
在哪里可以为与SES类相关的呼叫设置超时?
简单代码:
Exception
注意:我正在使用AWS开发工具包PHP PHP 3.67.20
失败时,我会收到此错误
use Aws\Ses\SesClient;
use Aws\Ses\Exception\SesException;
// Replace sender@example.com with your "From" address.
// This address must be verified with Amazon SES.
define('SENDER', 'sender@example');
// Replace recipient@example.com with a "To" address. If your account
// is still in the sandbox, this address must be verified.
define('RECIPIENT', 'recipient@example.com');
define('SUBJECT', 'Amazon SES test (AWS SDK for PHP)');
define('HTMLBODY', '<h1>AWS Amazon Simple Email Service Test Email</h1>' .
'<p>This email was sent with <a href="https://aws.amazon.com/ses/">' .
'Amazon SES</a> using the <a href="https://aws.amazon.com/sdk-for-php/">' .
'AWS SDK for PHP</a>.</p>');
define('TEXTBODY', 'This email was send with Amazon SES using the AWS SDK for PHP.');
define('CHARSET', 'UTF-8');
$_AWSAPICredentials = array(
'key' => 'AWSAPIKEY',
'secret' => 'AWSAPISECRET',
);
$_AWSAPIVersion = 'latest';
$_AWSAPIRegion = 'us-west-2';
$_SES = new SesClient([
'version' => $_AWSAPIVersion,
'region' => $_AWSAPIRegion,
'credentials' => $_AWSAPICredentials,
]);
$params = [
'Destination' => [
'ToAddresses' => [
RECIPIENT,
],
],
'Message' => [
'Body' => [
'Html' => [
'Charset' => CHARSET,
'Data' => HTMLBODY,
],
'Text' => [
'Charset' => CHARSET,
'Data' => TEXTBODY,
],
],
'Subject' => [
'Charset' => CHARSET,
'Data' => SUBJECT,
],
],
'Source' => SENDER
];
try {
$result = $_SES->sendEmail($params);
$sMessageId = $result->get('MessageId');
} catch (SesException $e) {
print_r($e->getAwsErrorMessage());
}
答案 0 :(得分:0)
好吧,我找到了解决方案...。我已经在服务器中同步了NTP Time,现在可以使用了。 我让我遵循的Ubuntu SO链接 https://www.tecklyfe.com/fix-ubuntu-timedatectl-ntp-sync-no/
也许我的机器的时钟至少是足够同步的,以至于每次都不会出现此错误。