PHP code example of okamos / php-ses

1. Go to this page and download the library: Download okamos/php-ses library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

okamos / php-ses example snippets


<php?

$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[]

// List all identities your domains.
$identities = $ses->ListIdentities('Domain');
// List all identities your email addresses.
$identities = $ses->ListIdentities('EmailAddress');
$identities[0]; // [email protected]

$ses->verifyEmailIdentity('[email protected]'); // return string(RequestId)

$ses->deleteIdentity('[email protected]'); // return string(RequestId)

$identities = [
    '[email protected]',
    '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)

$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(
    '[email protected]',
    'Subject',
    'Message',
);
$envelope->addTo('[email protected]');

$requestId = $ses->sendEmail($envelope);

$envelope = new SimpleEmailServiceEnvelope(
    '[email protected]',
    'Subject',
    'Message',
    '<p>Message</p><img src="http://example.com/any/image" alt="image"'
);
$envelope->addTo('[email protected]');

$requestId = $ses->sendEmail($envelope);

$envelope = new SimpleEmailServiceEnvelope(
    '[email protected]',
    'Subject',
    'Message',
);
$envelope->addTo(['[email protected]', '[email protected]']);
$envelope->addCc('[email protected]');
$envelope->addBcc(['[email protected]'])

$requestId = $ses->sendEmail($envelope);

$envelope = new SimpleEmailServiceEnvelope(
    '[email protected]',
    'Subject',
    'Message',
);
$envelope->addTo('[email protected]');
$envelope->addAttachmentFromFile('filename.svg', '/Your/File/name.svg', 'image/svg');

$requestId = $ses->sendEmail($envelope);
bash
composer