Note that there are some explanatory texts on larger screens.

plurals
  1. POEmail Notification System Using PHP MySQL
    text
    copied!<p>I am currently working on a project that requires sending email notifications to users. The way it works, users follow certain catergories of posts/group, whenever there is a new post or comment under the post category/group they get email message notifying them with a snippet of the post itself. </p> <p>I am expecting to send upwards of 5000 emails daily. Is it effective to use cron job to fetch users and send the emails at intervals or is there a better means to push this email while avoiding blacklisting on my IP by email providers.</p> <p>Below is my table structure</p> <p>First Table</p> <pre><code>Notification ID // autoincrement message // the message sent to users createDate // date created </code></pre> <p>Second Table</p> <pre><code>User_Notification ID // auto increment userid // Id of users notification_id // id of notification from first table status // 0 or 1 </code></pre> <p>So whenever a post is added, I insert the notification in the first table (notification) and then fetch all followers of that group from another table (following) where i store userids and the group ids. I then insert for each user in the second table (user_notification).</p> <p>My cron job fetchs like 20 records from user_notification table and also fetch the notification message from notification table. I also fetch user email from my user table. </p> <pre><code>$firstquery = $lnk-&gt;mysqli-&gt;query("select * from user_notification where status=0 order by id ASC limit 0, 20", MYSQLI_USE_RESULT); $secondquery = $lnk-&gt;mysqli-&gt;query("select * from notification where id=$notification_id", MYSQLI_USE_RESULT); $thirdquery = $lnk-&gt;mysqli-&gt;query("select email from user_table where id IN($userids)", MYSQLI_USE_RESULT); for($no=0;$no&lt;counter;$no++)// loop to send emails { $lnk-&gt;emailsender($subject,$emailbody,$usr_email[$no]); } </code></pre> <p>Please is there any better way to do this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload