0

我已经使用 PHP SDK 设置了 AWS Ses 服务:

$this->client = SesClient::factory([
    'key' => $params['key'],
    'secretKey' => $params['secret_key'],
    'region' => 'eu-west-1',
    'base_url' => 'https://email-smtp.eu-west-1.amazonaws.com',
]);

$this->client->sendEmail($this->params());

public function params() {
    array(
        'Source' => 'verified@gmail.com',
        'Destination' => array(
            'ToAddresses' => array('receiver@yahoo.com')
        ),
        'Message' => array(
            'Subject' => array(
                'Data' => 'SES Testing',
                'Charset' => 'UTF-8',
            ),
            // Body is required
            'Body' => array(
                'Text' => array(
                    'Data' => 'My plain text email',
                    'Charset' => 'UTF-8',
                ),
                'Html' => array(
                    'Data' => '<b>My HTML Email</b>',
                    'Charset' => 'UTF-8',
                ),
            ),
        ),
        'ReplyToAddresses' => array( 'replyTo@email.com' ),
        'ReturnPath' => 'bounce@email.com'
    );
}

尝试发送电子邮件后,我收到此错误消息:

exception 'Guzzle\Http\Exception\CurlException' with message 
'[curl] 23: Failed writing body (0 != 86) [url] https://email-smtp.eu-west-1.amazonaws.com/' 
in C:\xampp\htdocs\myProject\protected\lib\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php:338

任何人都知道如何解决该错误?

cUrl 支持 SMTP,但smtp://email-smtp.eu-west-1.amazonaws.com抛出错误[curl] 1: Protocol smtp not supported or disabled in libcurl [url] smtp://email-smtp.eu-west-1.amazonaws.com/ 卷曲

4

3 回答 3

0

您没有使用有效的端点。

email-smtp.eu-west-1.amazonaws.com是 SMTP 端点,而不是 HTTPS。HTTPS 端点是email.eu-west-1.amazonaws.com.

http://docs.aws.amazon.com/general/latest/gr/rande.html#ses_region

于 2015-03-29T19:20:34.870 回答
0
  1. https://email.{$region}.amazonaws.com用作在此阶段,我收到错误:'用户'arn:aws:iam::######:user/ ebpush base_url
    '无权对资源'arn:aws:ses:执行'ses:SendEmail': eu-west-1:447362101282:identity/verified@gmail.com'
  2. 添加IAM >>创建组> AmazonSESFullAccess
  3. 转到IAM >策略> AmazonSESFullAccess >附加> ebPush

或者

使用 PHPMailer 连接,email-smtp.{region}.amazonaws.com其中用户名是您的 SES 访问密钥,密码是您的 SES 密钥

于 2015-03-30T11:01:56.247 回答
0

您无需在 AWS SDK for PHP 中显式设置 base_url/endpoint。设置区域将确保使用正确的端点。

于 2015-04-23T20:20:56.100 回答