riconect/mailerbundle

Mailer helper for Swiftmailer - spooling to database.

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.0.0 2016-08-29 23:25 UTC

This package is not auto-updated.

Last update: 2024-10-26 19:48:30 UTC


README

Latest Stable Version License

This bundle is a mail helper for Symfony framework.

At present, it only works with the Doctrine ODM (MongoDB).

Installation and configuration

1. Install via Composer

$ composer require "riconect/mailerbundle:^1.0"

2. Add the bundle to your application's kernel

// app/AppKernel.php
public function registerBundles()
{
    $bundles = [
        // ...
        new Riconect\MailerBundle\RiconectMailerBundle(),
        // ...
    ];
}

3. Configure SwiftMailer to use the bundle

# app/config/config.yml
swiftmailer:
    spool:
        type:  service
        id:    riconect_mailer.spool

That's it. Now your emails is saved to default database in messages collection.

4. Add cron job.

$ crontab -e

Add this line to execute command every minute:

* * * * * /usr/bin/php /PATH/TO/YOUR/PROJECT/bin/console swiftmailer:spool:send --message-limit=100 --env=dev > /dev/null

Don't forget to change options like --env=prod in production server.

If you wish to keep sent emails in database, configure the bundle:

# app/config/config.yml
riconect_mailer:
    keep_sent_emails: true

Default Configuration:

riconect_mailer:
    database_type:        mongodb
    keep_sent_emails:     false
    message_class:        Riconect\MailerBundle\Document\Message