Jump to content

Recommended Posts

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;
		}
	}
Link to comment
https://forums.phpfreaks.com/topic/279424-confirmation-message-in-for-each-loop/
Share on other sites

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.