Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending mass email with different attachments using cron job

I'm building a web application. One of the major feature of this application is, it sends email to all the users based on their preferences which can be set weekly or monthly. The email sending has to be executed using cron. The email will contain a csv or xml file which is actually a report for the user generated by the system. That means, each user will get different file. And there can be thousands of users. I'm using codeigniter framework for the app.

My question is, what will be the efficient way for this kind situation? I didn't use cronjob previously. So, I'm afraid about the server resources it will take for this kind of execution. I also want to know how much time it will take for sending 1000 such email and is their any chances of execution time out or server crash? And should I use codeigniter's built in email class?

like image 674
Rahman Ashik Avatar asked Dec 20 '25 13:12

Rahman Ashik


1 Answers

You should have no problem to run this type of task via cron jobs, as @Ranty says there is no timeout, in CLI the maximum execution time is set to unlimited.

The time that it will take depends on your server, the time to retrieve the csv that you will attach... as @Ranty says is a good choice to run your cronjobs at night.

And finally yes, if you are using CI why not use the codeigniter's built in email class? For running scripts via command line read this: http://ellislab.com/codeigniter/user-guide/general/cli.html

like image 91
m4t1t0 Avatar answered Dec 22 '25 04:12

m4t1t0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!