1. Go to this page and download the library: Download daniel-zahariev/php-aws-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/ */
daniel-zahariev / php-aws-ses example snippets
new SimpleEmailServiceMessage();
$m->addTo('Recipient Name <[email protected]>');
$m->setFrom('Sender <[email protected]>');
$m->setSubject('Hello, world!');
$m->setMessageFromString('This is the message body.');
$ses = new SimpleEmailService('AccessKey', 'SecretKey');
print_r($ses->sendEmail($m));
// Successful response should print something similar to:
//Array(
// [MessageId] => 0000012dc5e4b4c0-b2c566ad-dcd0-4d23-bea5-f40da774033c-000000
// [RequestId] => 4953a96e-29d4-11e0-8907-21df9ed6ffe3
//)
// Additionally you can set the content of the email via:
$m->setMessageFromFile('/path/to/some/file.txt');
$m->setMessageFromURL('http://example.com/somefile.txt');
// And have both Text and HTML version with:
$m->setMessageFromString($text, $html);
$m->setMessageFromFile($textfilepath, $htmlfilepath);
$m->setMessageFromURL($texturl, $htmlurl);
// Remember that setMessageFromString, setMessageFromFile, and setMessageFromURL are mutually exclusive.
// If you call more than one, then whichever call you make last will be the message used.
// You can also set the encoding of the Subject and the Message Body
$m->setSubjectCharset('ISO-8859-1');
$m->setMessageCharset('ISO-8859-1');
$m->addAttachmentFromData('my_text_file.txt', 'Simple content', 'text/plain');
$m->addAttachmentFromFile('my_PFD_file.pdf', '/path/to/pdf/file', 'application/pdf');
// SendRawEmail is explicitly used when there are attachments:
$ses->sendEmail($m);
// Sending raw email can be enforsed with:
$ses->sendEmail($m, $use_raw_request = true);
// Now you can add an inline file in the message
$m->addAttachmentFromFile('logo.png','path/to/logo.png','application/octet-stream', '<logo.png>' , 'inline');
// and use it in the html version of the e-mail: <img src='cid:logo.png' />
// Set the configuration set
$m->setConfigurationSet('myConfigurationSet');
// Reset the configuration set
$m->setConfigurationSet(null);
// Set message tag
$m->setMessageTag('key', 'value');
// Get message tag
$tag = $m->getMessageTag('key');
// Remove message tag
$m->removeMessageTag('key');
// Set message tags in bulk - performs merge with current tags
$m->setMessageTags(array('key1' => 'value1', 'key2' => 'value2'));
// Get message tags
$tags = $m->getMessageTags();
// Remove all message tags
$m->removeMessageTags();
// Enable bulk sending mode (reuse of CURL handler)
$ses->setBulkMode(true);
// Send the messages
foreach($messages as $message) {
$ses->sendEmail($message);
}
// Disable bulk sending mode
$ses->setBulkMode(false);
$region_endpoint = SimpleEmailService::AWS_US_EAST_1;
$ses = new SimpleEmailService('AccessKey', 'SecretKey', $region_endpoint);
// Get the addresses that have been verified in your AWS SES account
$ses->listVerifiedEmailAddresses();
// Delete a verified address
$ses->deleteVerifiedEmailAddress('[email protected]');
// Send a confirmation email in order to verify a new email
$ses->verifyEmailAddress('[email protected]');
// Get Send Quota
$ses->getSendQuota();
// Get Send Statistics
$ses->getSendStatistics()
// Set the default behaviour for handling errors
$trigger_error = true;
$ses = new SimpleEmailService('AccessKey', 'SecretKey', $region_endpoint, $trigger_error);
// Or overwrite the main setting on a single call
$use_raw_request = false;
$trigger_error = false;
$ses->sendEmail($m, $use_raw_request, $trigger_error);