3

听起来应该很难解决,但我无法让它工作。

我已经阅读了send_email的 API 参考 我已经阅读了与它相关的其他线程,这里和其他网站。我已经使用代码示例来确保我的参数数组正确嵌套(尽我所能),但一切都给出了“意外的列表元素终止”

function amazonSesEmail($to, $subject, $message)
{
    $amazonSes = new AmazonSES(); //

    $response = $amazonSes->send_email('my_ses_confirmed_email@gmail.com',
        array('ToAddresses' => $to),
        array(
            'Subject.Data' => $subject,
            'Body.Text.Data' => $message,
        )
    );

    return $response;
}

我也尝试过像这样的乱七八糟的东西,不顾一切地尝试遵循参考结构:

$aws_reply = $aws_ses->send_email(  $fromEmailAddress, 
            array('ToAddresses' => 'same@gmail.com'),
                array(
                 array(  'Subject' => array('Data' => 'New Request '),
                         'Body' =>    array( 'Text' => array('Data' => 'New Request '))
                       )  
               )
);

在我 print_r($response) 的所有情况下,这是详细信息:

CFResponse Object
(
    [header] => Array
        (
            [x-amzn-requestid] => xxxx-xxxxx
            [content-type] => text/xml
            [content-length] => 280
            [date] => Fri, 16 Dec 2011 03:24:07 GMT
            [_info] => Array
                (
                    [url] => https://xxxxx/
                    [content_type] => text/xml
                    [http_code] => 400
                    [header_size] => 166
                    [request_size] => 1088
                    [filetime] => -1
                    [ssl_verify_result] => 0
                    [redirect_count] => 0
                    [total_time] => 0.349242
                    [namelookup_time] => 0.156135
                    [connect_time] => 0.189468
                    [pretransfer_time] => 0.28083
                    [size_upload] => 185
                    [size_download] => 280
                    [speed_download] => 801
                    [speed_upload] => 529
                    [download_content_length] => 280
                    [upload_content_length] => 185
                    [starttransfer_time] => 0.349204
                    [redirect_time] => 0
                    [certinfo] => Array
                        (
                        )

                    [method] => POST
                )

            [x-aws-stringtosign] => Fri, 16 Dec 2011 03:24:06 GMT68492574-F715-4AE3-B153-9446AE80866D
            [x-aws-request-headers] => Array
                (
                    [Content-Length] => 185
                    [Content-MD5] => 9+iobwTmkId+4ZmGt+6CDw==
                    [Content-Type] => application/x-www-form-urlencoded; charset=utf-8
                    [Date] => Fri, 16 Dec 2011 03:24:06 GMT
                    [Host] => xxxxxxxxxx.com
                    [X-Amz-Nonce] => xxx
                    [X-Amzn-Authorization] => AWS3-HTTPS AWSAccessKeyId=xxx,Algorithm=HmacSHA256,SignedHeaders=Content-Length;Content-MD5;Content-Type;Date;Host;X-Amz-Nonce,Signature=xxxx
                )

            [x-aws-body] => Action=SendEmail&Destination.ToAddresses=xxxx%40gmail.com&Message.Body.Text.Data=test%20body&Message.Subject.Data=test%20subject&Source=xxxxx%40gmail.com&Version=2010-12-01
        )

    [body] => CFSimpleXML Object
        (
            [@attributes] => Array
                (
                    [ns] => http://xxxx
                )

            [Error] => CFSimpleXML Object
                (
                    [Type] => Sender
                    [Code] => MalformedInput
                    [Message] => Unexpected list element termination
                )

            [RequestId] => xxxxx
        )

    [status] => 400
)

我又一次把我的头发扯掉了,它应该是非常严格的,但我似乎无法满足它的格式要求,而且似乎对其他写过它的人有用的东西对我不起作用。以前做过这件事的人的任何意见将不胜感激!

4

3 回答 3

9

我今天也遇到了你报告的这个问题。经过一番折腾,我发现以下配置适用于 aws php sdk:sdk-1.5.3:

 $response = $ses->send_email($fromEmail,
      array('ToAddresses' => array($toEmail)),
           array(
                'Subject.Data' => $subject,
                'Body.Html.Data' => $content,
           )
 );

看看你和我的区别...

 $response = $amazonSes->send_email('my_ses_confirmed_email@gmail.com',
 array('ToAddresses' => $to), // problem is here
      array(
           'Subject.Data' => $subject,
           'Body.Text.Data' => $message,
      )
 );

在您的两个示例中,您都放置了$to未包含在数组中的“地址”。

迟到总比不到好!

于 2012-04-09T14:02:09.583 回答
0

我认为这与地址列表的格式化方式有关。我在让它与多个收件人一起工作时遇到了很多麻烦,但只用一个 ToAddress 来处理事情也非常棘手......

这可能会对您有所帮助:使用 Amazon SES 向多个收件人发送电子邮件

使用CFComplexType::map()有助于确保事物处于适合 SES 的结构中。

于 2012-01-02T22:00:10.017 回答
0

我没有让该方法工作,但我确实使用 php PEAR 包的 MAIL 扩展从 php 通过 SES 发送电子邮件。在 AWS 仪表板中,您可以将 SES 帐户设置为使用 SMTP 身份验证,所以我这样做了,现在 SES 允许我通过 smtp 按预期发送邮件。

希望这可以为其他人节省一些时间和头痛

于 2011-12-16T20:53:15.340 回答