, (*1)
This bundle is a mail helper for Symfony framework.
At present, it only works with the Doctrine ODM (MongoDB)., (*2)
Installation and configuration
1. Install via Composer
``` sh
$ composer require "riconect/mailerbundle:^1.0", (*3)
### 2. Add the bundle to your application's kernel
``` php
// app/AppKernel.php
public function registerBundles()
{
$bundles = [
// ...
new Riconect\MailerBundle\RiconectMailerBundle(),
// ...
];
}
``` yaml, (*4)
app/config/config.yml
swiftmailer:
spool:
type: service
id: riconect_mailer.spool, (*5)
That's it. Now your emails is saved to default database in `messages` collection.
### 4. Add cron job.
``` sh
$ crontab -e
Add this line to execute command every minute:, (*6)
* * * * * /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., (*7)
If you wish to keep sent emails in database, configure the bundle:, (*8)
``` yaml, (*9)
app/config/config.yml
riconect_mailer:
keep_sent_emails: true, (*10)
Default Configuration:
``` yaml
riconect_mailer:
database_type: mongodb
keep_sent_emails: false
message_class: Riconect\MailerBundle\Document\Message