waytonoway/mailer-ses-v4

Extension for sending emails via amazon ses V4

Installs: 123

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 19

Type:yii2-extension

v1.3.0 2021-04-13 11:09 UTC

This package is auto-updated.

Last update: 2024-04-13 18:13:08 UTC


README

Extension for sending emails via amazon ses v4. (based on daniel-zahariev/php-aws-ses)

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist waytonoway/mailer-ses-v4

or add

"waytonoway/mailer-ses-v4": "1.0.0"

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' => 'waytonoway\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();