嗨,我的代码运行完美的几天前,我今天检查有给予我错误,而使用亚马逊ses服务发送电子邮件
在“https://email.us-west-2.amazonaws.com“上执行“发送电子邮件”时出错;AWS HTTP错误:客户端错误:POST https://email.us-west-2.amazonaws.com
导致403 Forbidden
响应:发件人签名完成(已截断...)签名不匹配(客户端):签名过期日期:20160718 T125547 Z现在早于20160718 T125616 Z(20160718 T130116 Z- 5分钟)-发件人签名不匹配签名已过期:20160718 T125547 Z现在早于20160718 T125616 Z(20160718 T130116 Z- 5分钟)b64 acacc-4ce 7 - 11 e6-adb 5 - 0992 ceb 0921 c
我的密码是:
require_once("aws/aws-autoloader.php");
use Aws\Ses\SesClient;
define('SENDER', 'no-reply@example.net');
define('RECIPIENT', 'my@example.com');
define('REGION','us-west-2');
$client = SesClient::factory(array(
'version'=> 'latest',
'region' => REGION,
'credentials' => array(
'key' => '******************',
'secret' => '*****************************',
)
));
$request = array();
$request['Source'] = SENDER;
$request['Destination']['ToAddresses'] = array(RECIPIENT);
$request['Message']['Subject']['Data'] = $subject;
$request['Message']['Body']['Text']['Data'] = $message;
try {
$result = $client->sendEmail($request);
$messageId = $result->get('MessageId');
} catch (Exception $e) {
echo($e->getMessage()."\n");
}
我该怎么补救呢?
1条答案
按热度按时间y4ekin9u1#
来自Michael - sqlbot的评论:
像大多数服务器一样,Amazon服务器使用UTC,但问题可能不在于您的时区。任何好的库都能正确地处理必要的转换。您的时钟只需设置为所设置时区中正确的当前时间,过期和扭曲是同一个问题的两个典型症状(尽管不一定)。Ubuntu
sudo apt-get install ntp
。Amazon Linuxsudo yum install ntp
。即