如何在yii2中使用aws ses sendmail?

时间:2015-11-09 06:45:51

标签: php yii2 aws-sdk

Cache-Control: no-transform 

使用发送邮件功能时出现此错误:

<?php
namespace api\models;
require '../../vendor/autoload.php';

use Yii;
use Aws\Ses\SesClient;

class Mail
{
    public function sendSesEmail($to, $subject, $body="", $bodyHtml="")
    {
        try
        {
            $client = SesClient::factory(array(
                'version'     => 'latest',
                'region' => 'us-east-1',
                'credentials' => array(
                    'key'       => '**********',
                    'secret'    => '**********',
                  ),
            ));
            $emailSentId = $client->sendEmail(array(
                // Source is required
                'Source' => 'test@test.com',
                // Destination is required
                'Destination' => array(
                    'ToAddresses' => array($to)
                ),
                // Message is required
                'Message' => array(
                    // Subject is required
                    'Subject' => array(
                        // Data is required
                        'Data' => 'SES Testing',
                        'Charset' => 'UTF-8',
                    ),
                    // Body is required
                    'Body' => array(
                        'Text' => array(
                            // Data is required
                            'Data' => 'My plain text email',
                            'Charset' => 'UTF-8',
                        ),
                        'Html' => array(
                            // Data is required
                            'Data' => '<b>My HTML Email</b>',
                            'Charset' => 'UTF-8',
                        ),
                    ),
                ),
                'ReplyToAddresses' => array( 'replyTo@email.com' ),
                'ReturnPath' => 'bounce@email.com'
            ));
            return $emailSentId;
        }
        catch (SesException $exec) 
        {
            echo $exec->getmessage();
        }

    }
}
?>
     

执行Aws\Ses\Exception\SesException 时出错cURL错误60:SSL证书问题:无法获取本地颁发者证书(请参阅http://curl.haxx.se/libcurl/c/libcurl-errors.html)   ↵   引起:"SendEmail"

     

cURL错误60:SSL证书问题:无法获得本地颁发者证书(请参阅http://curl.haxx.se/libcurl/c/libcurl-errors.html

0 个答案:

没有答案