Jump to content

[SOLVED] Problem with sending mail ...


budimir

Recommended Posts

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>";
	}
}

Link to comment
https://forums.phpfreaks.com/topic/137892-solved-problem-with-sending-mail/
Share on other sites

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??

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.