drewlabs/envoyer-aws

AWS SES 和 Pinpoint 驱动程序,用于 envoyer 库

v0.2.0 2023-06-12 08:36 UTC

This package is auto-updated.

Last update: 2024-09-12 12:36:27 UTC


README

该库为 envoyer 客户端 提供 AWS SESAWS Pinpoint 服务的驱动程序/适配器。库中提供了一个 SESAdapter,作为访问 AWS Simple Email Service API 的接口,同时提供了一个 PinpointMessageAdapter,作为访问 Short Message Service 的接口。

用法

  • AWS SES 适配器
use Drewlabs\Envoyer\Drivers\Aws\SESAdapter;
use Drewlabs\Envoyer\Drivers\Aws\Utils\CredentialsFactory;
use Drewlabs\Envoyer\Mail;

$config = require __DIR__ . '/config.php';

// Build email
$mail = Mail::new()
    ->from($config['email'], 'SERVICES')
    ->to('...')
    ->subject('...')
    ->content('...');

// Create mail adapter
$adapter = SESAdapter::new([
    'region' => $config['region'],
    // Creates a promise object for aws credentials
    'credentials' => CredentialsFactory::create($config['user'], $config['password'])
]);

// Send mail request
$result = $adapter->sendRequest($mail);