riconect/mailerbundle

Swiftmailer 的邮件助手 - 将邮件存入数据库。

安装: 4

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

1.0.0 2016-08-29 23:25 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:20:12 UTC


README

Latest Stable Version License

此包是用于 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