baka / mail
Baka 组件,用于通过简单的队列接口处理电子邮件
v0.2.1
2019-05-11 09:19 UTC
Requires
- php: >=7.0
- ext-phalcon: >=3.0.0
- duncan3dc/fork-helper: ^2.2.0
- phalcon/incubator: >=3.0
- swiftmailer/swiftmailer: ^6
- symfony/var-dumper: ^4.2
Requires (Dev)
- codeception/codeception: 2.5.*
- codeception/verify: 0.4.0
- vlucas/phpdotenv: ^2.0
This package is auto-updated.
Last update: 2024-09-29 05:08:14 UTC
README
Baka 邮件包装器,用于 Swiftmailer 的队列
配置
SMTP
'email' => [ 'driver' => 'smtp', 'host' => getenv('EMAIL_HOST'), 'port' => getenv('EMAIL_PORT'), 'username' => getenv('EMAIL_USER'), 'password' => getenv('EMAIL_PASS'), 'from' => [ 'email' => 'noreply@domain.do', 'name' => 'YOUR FROM NAME', ], 'debug' => [ 'from' => [ 'email' => 'noreply@domain.do', 'name' => 'YOUR FROM NAME', ], ], ];
设置依赖注入
createMessage()
$di->set('mail', function () use ($config, $di) { //setup $mailer = new \Baka\Mail\Manager($config->email->toArray()); return $mailer->createMessage(); });
发送普通电子邮件()
$this->mail ->to('info@domain.do') ->subject('Test Normal Email queue') ->content('normal email send via queue') ->send(); ];
发送模板普通电子邮件()
$this->mail ->to('info@domain.dom') ->subject('Test Template Email queue') ->params(['name' => 'test']) ->template('email.volt') //you can also use template() default template is email.volt ->send(); ];
立即发送普通电子邮件,不使用队列()
$this->mail ->to('info@domain.do') ->subject('Test Normal Email now') ->content('send normal email now') ->sendNow(); ];
事件
mailer:beforeCreateMessage
mailer:afterCreateMessage
mailer:beforeSend
mailer:afterSend
mailer:beforeAttachFile
mailer:afterAttachFile
设置 CLI
use Phalcon\Cli\Task; /** * Class LsTask * @description('List directory content', 'The content will be displayed in the standard output') */ class MainTask extends Task { use Baka\Mail\JobTrait; }
运行 CLI
php app.php main mailqueue email_queue