budimir Posted December 21, 2008 Share Posted December 21, 2008 Hey guys, Can you tell me where is the problem in this peace of code. I'm trying to send an email from a newsletter system I've built. But, the mail is not delivered. There is no error message. It isn't delivering emails. //Početak slanja newslettera $sql = "SELECT * FROM newsletter_primatelji WHERE list_id = '$list_id'"; $result = mysql_query($sql,$veza) or die("ERROR IN QUERY:".$sql."<br>".mysql_error()); while($row = mysql_fetch_array($result)){ $primatelj[$row["email"]] = $row["ime"]; } //print_r($primatelj);die; require("e-posta_inc-html.php"); foreach ($primatelj as $key => $value){ include "newsletter_show.php"; $email_sadrzaj = $newsletter_show; //echo "$email_sadrzaj"; //die; $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("../phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "server"; $mail->SMTPAuth = false; $mail->Username = ""; $mail->Password = ""; $mail->From = $senderrr_email; $mail->FromName = "Drezga-Deržić d.o.o."; $mail->AddAddress($key); //Ovdje nisam siguran kaj ide ($key, $value ili $primatelj) $mail->AddReplyTo($senderrr_email, "Drezga-Deržić 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"],""); } if(!$mail->Send()) { $not_sent_arr[$key] = $value; } echo "<span style='font-family: Verdana; font-size: 11px;'>"; if ($not_sent_arr != ""){ echo "<b>Neuspjelo slanje:</b><br>"; foreach ($not_sent_arr as $key => $value){ echo $key." - ".$value."<br>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/137892-solved-problem-with-sending-mail/ Share on other sites More sharing options...
budimir Posted December 21, 2008 Author Share Posted December 21, 2008 Better said, the mail is delivered only to the first one in the list. It's not sending to any other emails in the mail list. When I take a look at my array with the email adresses I can see that everyone is inside. Any ideas??? What am I missing?? Quote Link to comment https://forums.phpfreaks.com/topic/137892-solved-problem-with-sending-mail/#findComment-720680 Share on other sites More sharing options...
redarrow Posted December 21, 2008 Share Posted December 21, 2008 But your selecting 1 user where id='$id' if u need all users email sent dont use a where clause. Quote Link to comment https://forums.phpfreaks.com/topic/137892-solved-problem-with-sending-mail/#findComment-720691 Share on other sites More sharing options...
budimir Posted December 21, 2008 Author Share Posted December 21, 2008 No, that's not it. In that part I'm getting only one user, because I wan't to know who is sending the email. All emails are here: $sql = "SELECT * FROM newsletter_primatelji WHERE list_id = '$list_id'"; $result = mysql_query($sql,$veza) or die("ERROR IN QUERY:".$sql."<br>".mysql_error()); while($row = mysql_fetch_array($result)){ $primatelj[$row["email"]] = $row["ime"]; } When I print out that array I can see that all the emails are inside. But when the mail is being sent, it's sent only to the first mail in the list. I'm not quite sure why! Quote Link to comment https://forums.phpfreaks.com/topic/137892-solved-problem-with-sending-mail/#findComment-720753 Share on other sites More sharing options...
redarrow Posted December 21, 2008 Share Posted December 21, 2008 so if you echo out $rowUsM["email"] what u see... you sure this dosent need looping $rowUsM = mysql_fetch_array($resultUsM); and why not mysql_fetch_assoc Quote Link to comment https://forums.phpfreaks.com/topic/137892-solved-problem-with-sending-mail/#findComment-720756 Share on other sites More sharing options...
budimir Posted December 21, 2008 Author Share Posted December 21, 2008 I got it. It was o problem with ending foreach loop ... Thanks for your effort ... Quote Link to comment https://forums.phpfreaks.com/topic/137892-solved-problem-with-sending-mail/#findComment-720766 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.