riconect / mailerbundle
Swiftmailer 的邮件助手 - 将邮件存入数据库。
1.0.0
2016-08-29 23:25 UTC
Requires
- php: >=5.3.3
- doctrine/mongodb-odm-bundle: ~3.0
- symfony/swiftmailer-bundle: ~2.1
This package is not auto-updated.
Last update: 2024-09-14 19:20:12 UTC
README
此包是用于 Symfony 框架的邮件助手。
目前,它仅与 Doctrine ODM (MongoDB) 兼容。
安装和配置
1. 通过 Composer 安装
$ composer require "riconect/mailerbundle:^1.0"
2. 将包添加到应用程序的内核
// app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Riconect\MailerBundle\RiconectMailerBundle(), // ... ]; }
3. 配置 SwiftMailer 以使用该包
# app/config/config.yml swiftmailer: spool: type: service id: riconect_mailer.spool
完成。现在您的邮件已保存到默认数据库中的 messages
集合。
4. 添加 cron 作业。
$ crontab -e
添加此行,每分钟执行一次命令
* * * * * /usr/bin/php /PATH/TO/YOUR/PROJECT/bin/console swiftmailer:spool:send --message-limit=100 --env=dev > /dev/null
别忘了在生产服务器上更改选项,如 --env=prod
。
如果您希望将发送的邮件保留在数据库中,请配置该包
# app/config/config.yml riconect_mailer: keep_sent_emails: true
默认配置
riconect_mailer: database_type: mongodb keep_sent_emails: false message_class: Riconect\MailerBundle\Document\Message