prasanth-gandiva/yii2-yashop-ses

Extension for sending emails via amazon ses

Installs: 20 767

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 19

Type:yii2-extension

v1.0.2 2016-04-26 12:07 UTC

This package is not auto-updated.

Last update: 2024-05-17 16:40:19 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 prasanth-gandiva/yii2-yashop-ses "*"

or add

"prasanth-gandiva/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 attachment file url, you may use the following code:

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