jplarar/ses-bundle

一个简单的用于 AWS SES API 的 Symfony2 扩展包。

安装: 988

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

1.2.0 2019-06-11 20:37 UTC

This package is auto-updated.

Last update: 2024-09-12 09:31:37 UTC


README

一个简单的用于 AWS SES API 的 Symfony2 扩展包。

设置

步骤 1: 使用 composer 下载 JplararSESBundle

在 composer.json 中添加 SES 扩展包

{
    "require": {
        "jplarar/ses-bundle": "^1.0.0"
    }
}

现在运行以下命令让 composer 下载扩展包:

$ php composer.phar update "jplarar/ses-bundle"

步骤 2: 启用扩展包

在内核中启用扩展包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Jplarar\SESBundle\JplararSESBundle()
    );
}

步骤 3: 添加配置

# app/config/config.yml
jplarar_ses:
        amazon_ses:
            amazon_ses_key:    %amazon_ses_key%
            amazon_ses_secret: %amazon_ses_secret%
            amazon_ses_region: %amazon_ses_region%

用法

使用服务

<?php
        $sesClient = $this->get('amazon_ses_client');
?>

##示例

###向 SES 发送新邮件

<?php 
    $result = $sesClient->sendEmail(
                'recipient@example.com', 
                'subject', 
                'sender@example.com', 
                '<h1>AWS Amazon Simple Email Service Test Email</h1>',
                'This email was send with Amazon SES using the AWS SDK for Symfony.'
            );
            
            $messageId = $result->get('MessageId');
            echo("Email sent! Message ID: $messageId"."\n");
?>