erenkucukersoftware / php-ses
PHP的Amazon SES API。支持签名版本4
7.0.0
2021-05-06 06:43 UTC
Requires
- php: ^7.2
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is not auto-updated.
Last update: 2024-09-21 00:26:06 UTC
README
php-ses 是用于 Amazon Simple Email Service REST API(亚马逊 SES)的 PHP 库 Amazon SES
安装
通过Composer安装
composer require okamos/php-ses
入门
要开始,您需要引入 ses.php
<php? require_once('vendor/autoload.php');
此库需要您的 AWS 访问密钥 ID 和 AWS 密钥访问密钥。
$ses = new SimpleEmailService( 'AKI...', // your AWS access key id 'your_secret...', // your AWS secret access key 'us-west-2' // AWS region, default is us-east-1 ); // if you can't use verification of SSL certificate $ses = new SimpleEmailService( 'AKI...', // your AWS access key id 'your_secret...', // your AWS secret access key 'us-west-2' // AWS region, default is us-east-1 ); // method name's first character is must be lower case $identities = $ses->listIdentities(); // string[]
版本指导
可用的API
- ListIdentities
- VerifyEmailIdentity
- DeleteIdentity
- SendEmail
- GetSendQuota
- GetSendStatistics
- GetIdentityVerificationAttributes
使用
列出身份。
// List all identities your domains. $identities = $ses->ListIdentities('Domain'); // List all identities your email addresses. $identities = $ses->ListIdentities('EmailAddress'); $identities[0]; // your@email.com
验证电子邮件。
$ses->verifyEmailIdentity('your-email@example.com'); // return string(RequestId)
删除一个身份。
$ses->deleteIdentity('your-email@example.com'); // return string(RequestId)
获取验证令牌和状态。
$identities = [ 'your-email@example.com', 'your-domain.com' ]; $entries = $ses->getIdentityVerificationAttributes($identities); $entries[0]['Email']; // string (email) $entries[0]['Token']; // string(token) $entries[1]['Status']; // string(Pending | Success | Failed | TemporaryFailure)
获取您的 AWS 账户的发送配额。
$sendQuota = $ses->getSendQuota(); $sendQuota['Max24HourSend'] // string $sendQuota['SentLast24Hours'] // string $sendQuota['MaxSendRate'] // string
获取您的发送统计信息。
$data = $ses->getSendStatistics(); $data['Complaints'] // string $data['Rejects'] // string $data['Bounces'] // string $data['DeliveryAttempts'] // string $data['Timestamp'] // string
发送电子邮件的基本用法。
$envelope = new SimpleEmailServiceEnvelope( 'your-email@example.com', 'Subject', 'Message', ); $envelope->addTo('to@example.com'); $requestId = $ses->sendEmail($envelope);
使用HTML发送电子邮件。
$envelope = new SimpleEmailServiceEnvelope( 'your-email@example.com', 'Subject', 'Message', '<p>Message</p><img src="http://example.com/any/image" alt="image"' ); $envelope->addTo('to@example.com'); $requestId = $ses->sendEmail($envelope);
向多个目的地发送电子邮件。
$envelope = new SimpleEmailServiceEnvelope( 'your-email@example.com', 'Subject', 'Message', ); $envelope->addTo(['to1@example.com', 'to2@example.com']); $envelope->addCc('cc1@example.com'); $envelope->addBcc(['bcc1@example.com']) $requestId = $ses->sendEmail($envelope);
带有附件文件(s)发送电子邮件。
$envelope = new SimpleEmailServiceEnvelope( 'your-email@example.com', 'Subject', 'Message', ); $envelope->addTo('to@example.com'); $envelope->addAttachmentFromFile('filename.svg', '/Your/File/name.svg', 'image/svg'); $requestId = $ses->sendEmail($envelope);