Take the tour ×

Symfony2 uses a Swiftmailer bundle to send emails.

In the perspective of creating periodical newsletters, it is interesting to understand if there is any possibility to set a timer to the email sending time. I.e., one prepares the email today and set a timer to let it to be sent tomorrow.

How can I do that in Symfony2?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

The first solution that comes to my mind is to store the newsletters in the database with publishAt and isPublished fields and create a command that will fetch the newsletters with NOW() >= publishAt AND isPublished = false, mail them and set the isPublished flag to true. The command will be run by cron.

share|improve this answer
add comment

First, there is no standard way to schedule periodic emails.

The best way I think is to use something like MailChimp where you can programmatically manage and schedule mailing campaigns. There is Symfony2 bundle for this - MZMailChimpBundle.

If you don't want to use MailChimp (or similar), then the solution by Elnur is very good.

Alternatively you can use mailing queue, but it is rather advanced topic and it is extra work for your case.

share|improve this answer
add comment

Your Answer


