sweelix / yii2-mailjet
PHP 5.6+ MailJet integration for the Yii framework
Installs: 633
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 3
Open Issues: 2
Type:yii2-extension
Requires
- php: >=5.6.0
- mailjet/mailjet-apiv3-php: ~1.2
- yiisoft/yii2: >=2.0.4
Requires (Dev)
- php: >=5.6.0
- codeception/codeception: *
This package is not auto-updated.
Last update: 2024-11-17 00:55:58 UTC
README
This extension allow the developper to use Mailjet as an email transport.
Installation
If you use Packagist for installing packages, then you can update your composer.json like this :
{ "require": { "sweelix/yii2-mailjet": "*" } }
Howto use it
Add extension to your configuration
return [ //.... 'components' => [ 'mailer' => [ 'class' => 'sweelix\mailjet\Mailer', 'token' => '<your mailjet token>', ], ], ];
You can send email as follow (using mailjet templates)
Yii::$app->mailer->compose('contact/html') ->setFrom('from@domain.com') ->setTo($form->email) ->setSubject($form->subject) ->setTemplateId(12345) ->setTemplateModel([ 'firstname' => $form->firstname, 'lastname' => $form->lastname, ->send();
For further instructions refer to the related section in the Yii Definitive Guide
Running the tests
Before running the tests, you should edit the file tests/_bootstrap.php and change the defines :
// ... define('MAILJET_FROM', '<sender>'); define('MAILJET_KEY', '<key>'); define('MAILJET_SECRET', '<secret>'); define('MAILJET_TO', '<target>'); define('MAILJET_TEMPLATE', 218932); define('MAILJET_TEST_SEND', false); // ...
to match your Mailjet configuration.
Contributing
All code contributions - including those of people having commit access - must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.
Fork the project, create a feature branch , and send us a pull request.