ramprasadm1986 / yii2-sendgrid
Sendgrid Mailer for Yii 2
Installs: 54
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- sendgrid/sendgrid: 2.2.1
This package is auto-updated.
Last update: 2024-10-23 16:07:27 UTC
README
Yii2 SendGrid
Sendgrid Mailer for Yii 2
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist ramprasadm1986/yii2-sendgrid "*"
or add
"ramprasadm1986/yii2-sendgrid": "1.0.2"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by :
To use Mailer, you should configure it in the application configuration like the following,
'components' => [ ... 'sendGrid' => [ 'class' => 'ramprasadm1986\sendgrid\Mailer', 'username' => 'your_user_name', 'password' => 'your password here', //'viewPath' => '@app/views/mail', // your view path here ], ... ],
To send an email, you may use the following code:
$sendGrid = Yii::$app->sendGrid; $message = $sendGrid->compose('contact/html', ['contactForm' => $form]); $message->setFrom('from@domain.com') ->setTo($form->email) ->setSubject($form->subject) ->send($sendGrid);