I want to send email notifications on every new upload, new comment, new post etc.
Right now I’m calling a function:
notify($user_id, $submitter_id, $post_id);
And notify() processes these ids and calls mail(), the mail is sent to the ‘submitter’ and people who’ve commented earlier. The problem is, the script is taking too long and since i’m sending an AJAX request to this script to save the comments also, the user ends up waiting for notify() to complete. it’s like a chaining process.
Can anyone suggest me a better way to do this?
I don’t want the Ajax script to wait for:
- Saving the comments
- and sending the emails at the same time.
And also I can’t use a cron since I want this to be instant, kind of like FB’s.
In FB and so on. it’s created like I think you may:
when you need update
notify, you insert to tableoutboundssome messageAnd script which is always running, or execute like by
cron, or, you can curl this script with set up timeout=1 for send messagesDon’t forget after successfuly sent