Akim
Akim

Reputation: 136

Send mailer Symfony2

I use Symfony2. My Action send a message and then redirect to a page.

Like this

public function myAction()
{
    ...
    some code 
    ...

    sendMessageWithSwiftMailer()
    ....

    return $this->redirect(Url);

}

This code work. But Url takes so much time to be opened. How can I first open the Url page and then send the message? Can anyone give me any idea?

Upvotes: 0

Views: 104

Answers (1)

Manolo
Manolo

Reputation: 26350

You can use:

swiftmailer:
    spool: { type: file }

in your config_prod.yml and:

swiftmailer:
    spool: { type: memory }

in your config.yml.

Then, in production environment, you can create a crontab job which executes this Symfony2 command:

app/console swiftmailer:spool:send

This command will send your spooled messages.

More info at symfony.com/doc/current/cookbook/email/spool.html

Upvotes: 1

Related Questions