Open-Source PHP Framework - Designed for rapid development of performance-oriented scalable applications

/mvc/components/amazonSes

[return to app]
1
<?php
/**
 * Interface to Amazon Simple Email Service (Amazon SES)
 */
class amazonSesComponent {
    /**
     * Initializes SES
     * @return SimpleEmailService
     */
    protected function _ses() {
        if (!class_exists('SimpleEmailService')) {
            require get::$config->packagesPath() . 'amazon-ses';
        }
        $ses = new SimpleEmailService(get::$config->AMAZON['accessKey'], get::$config->AMAZON['secretKey']);
        $ses->enableVerifyPeer(false);
        return $ses;
    }

    /**
     * Sends an email via Amazon SES
     *
     * Uses approximately the same method-signature as the email method that ships with Vork, so a drop in
 
replacement * for get::component('email')->sendEmail($args) that sends via the PHP mail() method using your local SMTP
 
server. * * Required argument keys are: to, from, subject, body * Optional key is: (boolean) html * * Depends on SimpleEmailService package from http://www.orderingdisorder.com/aws/ses/ * @param array $args - Valid keys are from, to, subject, body, (bool) html */ public function sendEmail(array $args) { extract($args); $ses = $this->_ses(); $m = new SimpleEmailServiceMessage(); $m->setFrom($from); $m->addTo($to); $m->setSubject($subject); if (isset($html) && $html) { $m->setMessageFromString(strip_tags($body), $body); } else { $m->setMessageFromString($body); } return $ses->sendEmail($m); } /** * Amazon requires all sender-addresses be verified before email will be delivered * During initial sandbox testing, recipient addresses must be verified too * * @param string $email */ public function sesVerifyEmailAddress($email) { return $this->_ses()->verifyEmailAddress($email); } }