php - Progress bar / animated.gif during phpmailer email send -


i created members based website , when post new articles, (similar blog post), use phpmailer send email out members requested email sent them.

the email contains new articles content. title, description etc..

i'm in beta testing stage right now, , 3 email accounts takes 9 seconds send out 3 email when make new post. 3 seconds per email.

i expect around 100 users on site, = 5 minutes send out emails.

question

is there way can hook real time progress bar show how time left when sending emails?

my setup this:

i have form connected action script.

<?php include($_server['document_root'] . "/core/init.php");  // new data $title          = $_post['title']; $description    = $_post['description'];  // query  $addnotice = db::getinstance()->insert('table1', array(     'title' => $title,     'description' => $description,  ));                          $id = isset($_post['id']); $users = db::getinstance()->query("select id, title, description table1");  $users = db::getinstance()->query("select email table2 notify= 'yes'");  foreach($users->results() $u){  user::sendnotification($u->email, $title, '<strong><h2>'.$title.'</h2></strong><p>'.$description.'</p>');  }  session::flash('newarticle', '<h3 class="white-tx" align="center">the article has been added!</h3>'); redirect::to('sitepage.php'); ?> 

the user::sendnotification comes user class file looks this.

    public function sendnotification($to, $subject, $body) {         require_once 'class.phpmailer.php';         $from       = "notifier@*******.com";         $mail       = new phpmailer();         $mail->issmtp(true);            // use smtp         $mail->ishtml(true);         $mail->smtpauth   = true;                  // enable smtp authentication         $mail->host       = "host***.*******.com"; // smtp host         $mail->port       =  465;                    // set smtp port         $mail->username   = "notifier@******.com";  // smtp  username         $mail->password   = "********";  // smtp password         $mail->setfrom($from, 'email robot');         $mail->addreplyto($from,'do not reply');         $mail->subject    = $subject;         $mail->msghtml($body);         $address = $to;         $mail->addaddress($address, $to);         $mail->send(); } 

a real time progress bar ideal, settle animated .gif loading image.

which tried adding action script:

echo '<table align="center" width="100%" height="100%" border="0"><tr align="center" valign="center"><td><img src="images/sending.gif"></td></tr></table>'; 

but wasn't recognized , rolled right past sending.gif image , posted article website , sent emails.

i've searched google tutorials on subject, came dry.

any thoughts on situation appreciated.

i'd suggest use bcc of 1 email if not send personalized mails.

if want go progress bar, here's sketch of 1 way go:

  • add database table notifications fields user_id, notice_id
  • insert 1 row every user where notify= 'yes' (why not bool here?) , new notice
  • have cronjob poll table every , sending mails (by fetching appropriate info user , notice table) , removing respective pending rows
  • provide script returning current number of pending notifications (json) (num rows of notification table)
  • use js (i.e. jquery) periodic updates (http query aforementioned script)

(you have boolean field sent if not want delete rows notification table want track notifications.)

you have:

  • a submit.php insert required notifications table
  • a mail sending cronjob (i.e. php script or whatever) removes pending rows after sending
  • a poll.php provide current number of rows of notifications table in json format.
  • a status.php periodically request data poll.php , update page accordingly

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -