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 = "[email protected]"; } //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; } } Link to comment https://forums.phpfreaks.com/topic/279424-confirmation-message-in-for-each-loop/ 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? Link to comment https://forums.phpfreaks.com/topic/279424-confirmation-message-in-for-each-loop/#findComment-1437251 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.