budimir Posted June 21, 2013 Share Posted June 21, 2013 Guys, How to display a confirmation message after each mail is sent so I could see the progress. Now I can see complete list when loop finishes. I would like to display a status when email is sent or not in real time. This is my code foreach ($primatelj as $key => $value){ include "newsletter_show.php"; $email_sadrzaj = $newsletter_show; $sqlUsM = "SELECT * FROM korisnici WHERE id = '$user_id'"; $resultUsM = mysql_query($sqlUsM,$veza) or die (mysql_error()); $rowUsM = mysql_fetch_array($resultUsM); $senderrr_email = $rowUsM["email"]; if ($senderrr_email == ""){ $senderrr_email = "husqvarna@drezga.hr"; } //require_once("e-posta_inc-html.php"); require_once("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPKeepAlive = 'true'; $mail->Host = "server"; $mail->SMTPAuth = false; $mail->Username = ""; $mail->Password = ""; $mail->SMTPDebug = 1; $mail->Timeout = "60"; $mail->From = $senderrr_email; $mail->FromName = "Drezga d.o.o."; $mail->AddAddress($key); $mail->AddReplyTo($senderrr_email, "Drezga d.o.o."); // Optional: Specify character coding and encoding $mail->CharSet = "utf-8"; $mail->Encoding = "quoted-printable"; $mail->IsHTML(true); $mail->Subject = $naziv; $mail->Body = $email_sadrzaj; $sql_att = "SELECT * FROM newsletter_privici WHERE newsletter_id = '$newsletter_id' AND file1 != '' ORDER by priv_id"; $result_att = mysql_query($sql_att,$veza) or die (mysql_error()); while($row_att = mysql_fetch_array($result_att)){ $mail->AddAttachment("privici/".$row_att["file1"],""); $mail->AddAttachment("privici/".$row_att["file2"],""); $mail->AddAttachment("privici/".$row_att["file3"],""); } //print_r($value); //print "<br/>"; if(!$mail->Send()) { $not_sent_arr[$key] = $value; } } Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 21, 2013 Share Posted June 21, 2013 You are confused with the concept of server response and real-time response. PHP doesn't do realtime response - it's on the server. If you want realtime response, you probably want to use JS or Ajax. But do you really really need a realtime response for mutltiple activities? PHP is probably going to send all your emails in a matter of seconds, so what's the rush on getting a confirmation so fast? If you are executing any kind of a loop to complete a series of tasks, do you really want to interrupt it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.