Amazon ses extension for Yii2 with Attachment File URL
Extension for sending emails via amazon ses. Part of YaShop, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist prasanth-gandiva/yii2-yashop-ses "*"
or add, (*4)
"prasanth-gandiva/yii2-yashop-ses": "*"
to the require section of your composer.json
file., (*5)
Usage
To use this extension, you should configure it in the application configuration like the following:, (*6)
'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:, (*7)
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:, (*8)
$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();