yarcode / yii2-email-manager
Yii2 Email Manager
Installs: 1 661
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 4
Open Issues: 2
Requires
- php: >=5.4.0
- baibaratsky/yii2-serialized-attributes-behavior: ~1.1
- mailgun/mailgun-php: ^2.0
- php-http/guzzle6-adapter: ~1.0
- trntv/yii2-aceeditor: ~2.0
- yiisoft/yii2: ~2.0.4
- yiisoft/yii2-twig: ~2.0.3
Suggests
- cboden/ratchet: to use loop instead of for-cycle in daemon
This package is not auto-updated.
Last update: 2024-12-19 02:16:20 UTC
README
Installation
Simple configuration:
'components' => [
'emailManager' => [
'class' => '\yarcode\email\EmailManager',
'transports' => [
'yiiMailer' => '\yarcode\email\transports\YiiMailer'
],
],
]
Multi transport configuration:
'components' => [
'emailManager' => [
'class' => '\yarcode\email\EmailManager',
'defaultTransport' => 'yiiMailer',
'transports' => [
'yiiMailer' => [
'class' => '\yarcode\email\transports\YiiMailer',
],
'mailGun' => [
'class' => '\yarcode\email\transports\MailGun',
'apiKey' => 'xxx',
'domain' => 'our-domain.net',
],
],
],
]
Add command to the list of the available commands. Put it into console app configuration:
'controllerMap' => [
'email' => '\yarcode\email\commands\EmailCommand',
],
Add email sending daemon into crontab via lockrun or run-one utils:
*/5 * * * * run-one php /your/site/path/yii email/run-spool-daemon
OR, if you will use cboden/ratchet
*/5 * * * * run-one php /your/site/path/yii email/run-loop-daemon
Usage
// obtain component instance
$emailManager = EmailManager::geInstance();
// direct send via default transport
$emailManager->send('from@example.com', 'to@example.com', 'test subject', 'test email');
// queue send via default transport
$emailManager->send('from@example.com', 'to@example.com', 'test subject', 'test email');
// direct send via selected transport
$emailManager->transports['mailGun']->send('from@example.com', 'to@example.com', 'test subject', 'test email');
// use shortcuts
EmailTemplate::findByShortcut('shortcut_name')->queue('recipient@email.org', ['param1' => 1, 'param2' => 'asd']);