ofat/yii2-yashop-ses

This package is abandoned and no longer maintained. The author suggests using the prasanthsGandiva/yii2-ses package instead.

Extension for sending emails via amazon ses

Installs: 111 612

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 5

Forks: 19

Open Issues: 6

Type:yii2-extension

v1.0.3 2016-12-07 16:13 UTC

This package is auto-updated.

Last update: 2022-04-14 14:02:39 UTC


README

Extension for sending emails via amazon ses. Part of YaShop

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist ofat/yii2-yashop-ses "*"

or add

"ofat/yii2-yashop-ses": "*"

to the require section of your composer.json file.

Usage

To use this extension, you should configure it in the application configuration like the following:

'components' => [
    ...
    'mail' => [
        'class' => 'yashop\ses\Mailer',
        'access_key' => 'Your access key',
        'secret_key' => 'Your secret key',
        'host' => 'email.us-east-1.amazonaws.com' // not required
    ],
    ...
],

To send an email, you may use the following code:

Yii::$app->mail->compose('contact/html', ['contactForm' => $form])
    ->setFrom('from@domain.com')
    ->setTo($form->email)
    ->setSubject($form->subject)
    ->send();

To send an email with headers, you may use the following code:

Yii::$app->mail->compose('contact/html', ['contactForm' => $form])
    ->setFrom('from@domain.com')
    ->setTo($form->email)
    ->setSubject($form->subject)
    ->setHeader('Precedence', 'bulk')
    ->setHeader('List-id', '<1>')
    ->setHeader('List-Unsubscribe', Url::to(['user/unsubscribe'], true))
    ->send();

Increase the speed of sending emails:

Yii::$app->mailer->getSES()->enableVerifyHost(false);
Yii::$app->mailer->getSES()->enableVerifyPeer(false);
Yii::$app->mailer->getSES()->enableKeepAlive();

foreach ($emails as $email) {
    Yii::$app->mail->compose('delivery/mail', [])
        ->setFrom('from@domain.com')
        ->setTo($email)
        ->setSubject($subject)
        ->setHeader('Precedence', 'bulk')
        ->setHeader('List-id', '<1>')
        ->setHeader('List-Unsubscribe', Url::to(['user/unsubscribe'], true))
        ->send();
}

Yii::$app->mailer->getSES()->enableKeepAlive(false);