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 = "husqvarna@drezga.hr";
		}


	//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
Share on other sites

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!

Link to comment
Share on other sites

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.