我已经注册了亚马逊SES服务与电子邮件限制设置和沙盒。我已经尝试了许多PHPMailer函数,并且都返回错误:连接超时(110)。有可能从PHPMailer发送邮件吗?
我在亚马逊SES网站上看到了这个链接。
<?php
// Replace path_to_sdk_inclusion with the path to the SDK as described in
// http://docs.aws.amazon.com/aws-sdk-php/v2/guide/quick-start.html
define('REQUIRED_FILE','path_to_sdk_inclusion');
// Replace sender@example.com with your "From" address.
// This address must be verified with Amazon SES.
define('SENDER', 'sender@example.com');
// 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');
// Replace us-west-2 with the AWS region you're using for Amazon SES.
define('REGION','us-west-2');
define('SUBJECT','Amazon SES test (AWS SDK for PHP)');
define('BODY','This email was sent with Amazon SES using the AWS SDK for PHP.');
require REQUIRED_FILE;
use AwsSesSesClient;
$client = SesClient::factory(array(
'version'=> 'latest',
'region' => REGION
));
$request = array();
$request['Source'] = SENDER;
$request['Destination']['ToAddresses'] = array(RECIPIENT);
$request['Message']['Subject']['Data'] = SUBJECT;
$request['Message']['Body']['Text']['Data'] = BODY;
try {
$result = $client->sendEmail($request);
$messageId = $result->get('MessageId');
echo("Email sent! Message ID: $messageId"."n");
} catch (Exception $e) {
echo("The email was not sent. Error message: ");
echo($e->getMessage()."n");
}
?>
我已经复制了所有的代码,把我的变量,而不是显示在演示脚本。现在我得到了错误:你必须使用KEY和SECRET_KEY来使用这个脚本…在哪里我不能把我的KEY和SECRETKEY在脚本?
是否有其他方式通过亚马逊SES服务发送电子邮件?谢谢!
就这么简单。我必须在
中添加key和secret$client = SesClient::factory(array(
'version'=> 'latest',
'region' => REGION,
'credentials' => array(
'key' => 'XXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXX',
)
));
和设置XXXXXXXXXXXXXXXX完全访问api在亚马逊安全凭据
据我所知PHP Mailer不能通过API与AWS SES一起工作,您应该将SES SMTP与PHP Mailer一起使用。
正确的端口是25,465或587