CodeIgniter Forums

Full Version: Sending Email in Background
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

My system needs to send email to many users, and it really takes time to send many users. I do not want users to wait that time.

_send_mail functions are in various controller file per purpose. Is there any way we can send email in background?

If I use exec(), how do we keep all user email list, and mailing contents?

Thanks in advance
For background you can use CRON JOB.
You can store email addresses in database (MySQL or MariaDB etc...)
For email contents you can create Email Templates store it into sub folder and call these templates through CRON JOB.

Hope that helps.
I just made an outgoing mail queue that is very much like what solidcodes describes, only I am storing the entire body of the email in the database record. All f the connection details, from, to, reply to,etc. Cron runs once a minute to process the mail queue.
@skunkbad

DRY? that's nice...
(12-14-2015, 07:57 PM)solidcodes Wrote: [ -> ]@skunkbad

DRY? that's nice...

Actually, what I created a Mail driver to queue up the emails, and it is a driver because it has the ability to send emails via CI or swiftmailer. We ran into a problem where the host was telling us that CI was causing our emails to fail, so had to implement swiftmailer.