Jump to content

Recommended Posts

Hi I am really desperate to figure this issue out -so I hope that someone can help me here. 

 

I have a file cron.pop3.php -- that is supposed to check e-mails for bounced messages and then delete all the messages in the inbox -- but it isn't working and I can't seem to figure it out.  I know enough about php to "fumble" through- but not enough to proficiently debug this issue.  Any help would be greatly appreciated.

 

Here is the code in question:

 

<?php

require_once('commoninclude.php');

require_once("class.phpmailer.php");

 

$mail = new PHPMailer();

$pop_setings=Pop_Account_Settings();

$counter=count($pop_setings);

if($counter!==0)

{

    for($x=0;$x<count($pop_setings);$x++)

{

    $mbox = @imap_open($pop_setings[$x][20],$pop_setings[$x][21],$pop_setings[$x][22]);

if($mbox !== false)

  {

                $check = imap_check($mbox);

$totalmessages = $check->Nmsgs;

for($y=1;$y<=$totalmessages;$y++)

{

$header = imap_header($mbox,$y);

if($header !== false)

{

  $subject_email = $header->Subject;

  $body_email = imap_body($mbox,$y);

  $body_length = strlen($body);

                            $array_header=object_to_array($header);

  $to_email=$array_header['to']['0']['mailbox'] . "@" . $array_header['to']['0']['host'];

      if($pop_setings[$x][23]=="Y")

  {

  if(($subject_email == $pop_setings[$x][25]) &&  ($to_email==$pop_setings[$x][24]))

    {

      $full_name = $header->fromaddress;

      $name_array=explode(" ",trim($full_name));

      if($name_array[0]!="" && $name_array[1]!="" && $name_array[0]!=" " && $name_array[1]!=" ")

      {

        $from_name=$name_array[0];

$last_name=$name_array[1];

      }

      else

      {

      $from_name=$full_name;

      $last_name="";

      }

$from_email=$array_header['from']['0']['mailbox'] . "@" . $array_header['from']['0']['host'];

      $check1=Check_Email_Existing($pop_setings[$x][1],$from_email);

  $row_setting=View_Setting($pop_setings[$x][1]);

  $tracking_links=GetAllTracking_links($pop_setings[$x][1]);

                              $cnt=count($tracking_links);

                              $All_group=GetAllGroupName($pop_setings[$x][1]);

                              $campaign_list=Show_Selected_Campaign($pop_setings[$x][1]);

///////////////////////////////////////////

        if($check1==0)

        {

if($row_setting[10]=="Single")

            {

  $subs_type="Email";

  $ip_address=$_SERVER['REMOTE_ADDR'];

  $sign_up_url=$_SERVER['HTTP_REFERER'];

  $data1="insert into ".SUBSCRIBERS_TABLE." (campid,name,email,date_of_join,status,subs_type,ip_address,sign_url) values(".$pop_setings[$x][1].",'".$from_name."','".$from_email."','".offset_date()."',1,'".$subs_type."','".$ip_address."','".$sign_up_url."')";

      $result1=db_query($data1);

                        $getid="select max(id) from ".SUBSCRIBERS_TABLE ."";

      $q=db_query($getid);

      $rsgetid=db_fetch_row($q);

                  $subs_id=$rsgetid[0];

/////////////////////////////////////////////////////////////////////////////////  

//==coding for  remove same mail id if exist in other campaign

  $existing_camp_id=Check_Email_Existing_In_All_Subscribers($from_email);

for($z=0;$z<count($existing_camp_id);$z++)

$rowsetting_new_camp=View_Setting($existing_camp_id[$z][1]);

if($rowsetting_new_camp[18]!="")

{

  $camp_name_list=$rowsetting_new_camp[18];

  $camp_array=explode(",",$camp_name_list);

  for($y=0;$y<count($camp_array);$y++)

{

$new_campid=Show_Campaign_Id($camp_array[$y]);

if($new_campid==$pop_setings[$x][1])

{

$new_status=0;

$query="update ".SUBSCRIBERS_TABLE." set status=".$new_status." where  id = ".$existing_camp_id[$z][0];

$q =db_query($query)or die (db_error());

}

}

  }

}  

 

 

//=====================from here code for  zero delay mail to these subscribers

  $content=Show_Confirm_Message_Campain_Queue($pop_setings[$x][1]);

  if(($content!="") && ($row_setting[14]!="on"))

{

 

$msgid=$content[0];

$subject=$content[2];

$body=$content[3];

////////////////////////////////////////////////

/////==modified code for links personalisation==////////

$read_online=explode("#OnlineReadLink(",$body);

$read_online=explode(")#",$read_online[1]);

$online_text=$read_online[0];

 

$link_unsub=explode("#UnsubscribeLink[",$body);

$link_unsub=explode("]#",$link_unsub[1]);

$unsub_text=$link_unsub[0];

//////================end here================//

/////////////////////////////////////////////////

$date=offset_date();

$current_date=offset_date();

$subject=str_replace("#Name#",$from_name,$subject);

$subject=str_replace("#LastName#",$last_name,$subject);

$subject=str_replace("#EmailId#",$from_email,$subject);

$subject=str_replace("#IPAddress#",$ip_address,$subject);

$subject=str_replace("#JoinDate#",$date,$subject);

$subject=str_replace("#SignupUrl#",$sign_up_url,$subject);

 

$body=str_replace("#Name#",$from_name,$body);

$body=str_replace("#LastName#",$last_name,$body);

$body=str_replace("#EmailId#",$from_email,$body);

$body=str_replace("#IPAddress#",$ip_address ,$body);

$body=str_replace("#JoinDate#",$date,$body);

$body=str_replace("#SignupUrl#",$sign_up_url,$body);

$body=str_replace("#CurrentDate#",$current_date,$body);

 

for($i=0;$i<=$cnt-1;$i++)

{

$var = $basepath."getcode.php?id={$tracking_links[$i][3]}&email=#EmailId#";

$var_new=str_replace("#EmailId#",urlencode($from_email),$var);

$var_link="<a href='$var_new'>$var_new</a>";

$body=str_replace("#".$tracking_links[$i][5]."#",$var_link,$body);

}

 

                    for($m=0;$m<count($All_group);$m++)//this loop is for group

{

  $random_link_in_group=Select_Random_Link($All_group[$m][0]);

  $total_link=count($random_link_in_group);

  $random_link=rand(1,$total_link);

  $new_random_link=($random_link-1);

  $variable = $basepath."getcode.php?id={$random_link_in_group[$new_random_link][3]}&email=#EmailId#";

  $variable_new=str_replace("#EmailId#",urlencode($from_email),$variable);

  $variable_link="<a href='$variable_new'>$variable_new</a>";

  $body=str_replace("#".$All_group[$m][2]."#",$variable_link,$body);

}

 

for($p=0;$p<count($campaign_list);$p++)

{

$upgrade=$basepath."upgrade.php?id=".$subs_id."&cid=".$campaign_list[$p][0]."&em=".urlencode($from_email);

$upgrade_new="<a href='$upgrade'>$upgrade</a>";

$body=str_replace("#".$campaign_list[$p][1]."#",$upgrade_new,$body);

}

/////////////////////////////////////////////////////////

//==This code is for message display according to type==//

$contenttype=$content[7];

$total_msg_read = $basepath."total_message_read.php?id=".$msgid."&msg_methode=queue&email_id=".$from_email."&campid=".$pop_setings[$x][1];

$total_read="<img src='$total_msg_read' width'0' height='0'>";

    $line_break="<br>";

if ($contenttype=="text")

{

 

  $unsubscribe_url=$unsub_text."::".$basepath."unsubscribe.php?id=".$subs_id."&cid=".md5($from_email.$pop_setings[$x][1]);

  $server_message=$online_text."::".$basepath."server.php?id=".$subs_id."&campid=".$pop_setings[$x][1]."&msgmtd=queue&msgid=".$msgid;

  $body=str_replace("#UnsubscribeLink[".$unsub_text."]#",$unsubscribe_url,$body);

  $body=str_replace("#OnlineReadLink(".$online_text.")#",$server_message,$body);

  $confirm_message=url2link($body)." ".$line_break." ".$total_read;

}

 

elseif($contenttype=="html")

{

 

$var = $basepath."unsubscribe.php?id=".$subs_id."&cid=".md5($from_email.$pop_setings[$x][1]);

$var_msg=$basepath."server.php?id=".$subs_id."&campid=".$pop_setings[$x][1]."&msgmtd=queue&msgid=".$msgid;

 

$unsubscribe_url="<a href='$var' title='Click Here To unsubscribe us'>".$unsub_text."</a>";

$server_message="<a href='$var_msg' title='If You are not able to read this email properly then click here to read this email online'>".$online_text."</a>";

 

$body=str_replace("#UnsubscribeLink[".$unsub_text."]#",$unsubscribe_url,$body);

$body=str_replace("#OnlineReadLink(".$online_text.")#",$server_message,$body);

$confirm_message=$body." ".$line_break." ".$total_read;

}

/////////===End code==//////////////////

////////////////////////////////////////////////////////

////===============================Code  for email delievery=============================

//=======================================================================================                           

                            $mail_type_settings=View_Priority_Settings();

                            $mail->Priority=$mail_type_settings[0];

                            $setMailSendType=$mail_type_settings[1];

    $mail->CharSet=$mail_type_settings[5];

                         

if(isset($setMailSendType) && ($setMailSendType=="smtp"))

                                {

                                  $smtp_row=View_Setting_Smtp();

$mail->Mailer = "smtp";

$mail->Host=$smtp_row[0];

$mail->Port=$smtp_row[1];

                               

if ($smtp_row[4]=="true")

{

$mail->SMTPAuth=true;

$mail->Username=$smtp_row[2];

$mail->Password=$smtp_row[3];

}

else

{

                                  $mail->SMTPAuth=false;

$mail->Username="";

$mail->Password="";

}

                                 

                  }//sendmail settings

                              elseif(isset($setMailSendType) && ($setMailSendType=="sendmail"))

                              { 

$mail->Mailer = "sendmail";

$path=View_SendMail_Path();

$mail->Sendmail = $path[0];

}

 

        $dir="uploadedimages/";

    $attfile=$dir.$content[4];

$mail->From=$row_setting[3];

$mail->FromName = $row_setting[2];          //fromname means sender Email Id

$mail->ContentType ="text/html";

$mail->AddAddress($from_email);              // Reciepients Id

$mail->Subject= stripslashes($subject);

        $mail->Body = stripslashes($confirm_message);

        $mail->AddAttachment($attfile);

if($mail->Send())

{

$sending_way= "queue";

Save_Sent_Message($pop_setings[$x][1],$subs_id,$msgid,$from_email,$sending_way);

$mail->ClearAddresses();

}

 

//=====================Admin report=======================

if($row_setting[7]=="on")

{

Confirmation_Mail_to_Admin($pop_setings[$x][1],$from_name,$last_name,$from_email,$ip_address,$sign_up_url,$row_setting[3],$row_setting[2],$row_setting[8]);

}

}

} //end of if of single opt_in if loop

else //start of double opt in type

{

  $subs_type="Email";

  $ip_address=$_SERVER['REMOTE_ADDR'];

  $sign_up_url=$_SERVER['HTTP_REFERER'];

  $data1="insert into ".SUBSCRIBERS_TABLE." (campid,name,email,date_of_join,status,subs_type,ip_address,sign_url,last_name) values(".$pop_setings[$x][1].",'".$from_name."','".$from_email."','".offset_date()."',0,'".$subs_type."','".$ip_address."','".$sign_up_url."','".$last_name."')";

  $result1=db_query($data1);

                          $subs_id= db_insert_id();

                          $date = offset_date();

                          // $subs_details=View_Subscribers_details_By_mail_campid($from_email,$pop_setings[$x][1]);

//  $subs_id=$subs_details[0][0];

//  $date=$subs_details[0][4];

                         

/////////////////////////////////////////////////////////////////////////////////  

//==coding for  remove same mail id if exist in other campaign

  $existing_camp_id=Check_Email_Existing_In_All_Subscribers($from_email);

for($z=0;$z<count($existing_camp_id);$z++)

{

$rowsetting_new_camp=View_Setting($existing_camp_id[$z][1]);

if($rowsetting_new_camp[18]!="")

{

  $camp_name_list=$rowsetting_new_camp[18];

  $camp_array=explode(",",$camp_name_list);

  for($y=0;$y<count($camp_array);$y++)

{

$new_campid=Show_Campaign_Id($camp_array[$y]);

if($new_campid==$pop_setings[$x][1])

{

$new_status=0;

$query="update ".SUBSCRIBERS_TABLE." set status=".$new_status." where  id = ".$existing_camp_id[$z][0];

$q =db_query($query)or die (db_error());

}

}

  }

}  

/////////////////////////////////////////////////////////////////////////

 

    if($row_setting[14]!="on")

{

 

$verify_lk=$basepath."confirm.php?id=".$subs_id."&cid=".$pop_setings[$x][1]."&em=".urlencode($from_email);

$verifylink="<a href='$verify_lk'>$verify_lk</a>";

$subject=$row_setting[12];

$body=$row_setting[13];

        $subject=str_replace("#Name#",$from_name,$subject);

$subject=str_replace("#LastName#",$last_name,$subject);

$subject=str_replace("#EmailId#",$from_email,$subject);

$subject=str_replace("#IPAddress#",$ip_address,$subject);

$subject=str_replace("#JoinDate#",$date,$subject);

$subject=str_replace("#SignupUrl#",$sign_up_url,$subject);

$subject=str_replace("#VerifyLink#",$verifylink,$subject);

 

 

$body=str_replace("#Name#",$from_email,$body);

$body=str_replace("#LastName#",$last_name,$body);

$body=str_replace("#EmailId#",$from_email,$body);

$body=str_replace("#IPAddress#",$ip_address,$body);

$body=str_replace("#JoinDate#",$date,$body);

$body=str_replace("#SignupUrl#",$sign_up_url,$body);

$body=str_replace("#VerifyLink#",$verifylink,$body);

 

for($i=0;$i<=$cnt-1;$i++)

{

$var = $basepath."getcode.php?id={$tracking_links[$i][3]}&email=#EmailId#";

$var_new=str_replace("#EmailId#",urlencode($from_email),$var);

$var_link="<a href='$var_new'>$var_new</a>";

$body=str_replace("#".$tracking_links[$i][5]."#",$var_link,$body);

}

 

for($m=0;$m<count($All_group);$m++)//this loop is for group

{

  $random_link_in_group=Select_Random_Link($All_group[$m][0]);

  $total_link=count($random_link_in_group);

  $random_link=rand(1,$total_link);

  $new_random_link=($random_link-1);

  $variable = $basepath."getcode.php?id={$random_link_in_group[$new_random_link][3]}&email=#EmailId#";

  $variable_new=str_replace("#EmailId#",urlencode($from_email),$variable);

  $variable_link="<a href='$variable_new'>$variable_new</a>";

  $body=str_replace("#".$All_group[$m][2]."#",$variable_link,$body);

}

////////////////////////////////////////////////////////////////////////////////////////////

////===============================Code  for email delievery=============================

//=======================================================================================                           

$mail_type_settings=View_Priority_Settings();

$mail->Priority=$mail_type_settings[0];

$setMailSendType=$mail_type_settings[1];

$mail->CharSet=$mail_type_settings[5];

                    if(isset($setMailSendType) && ($setMailSendType=="smtp"))

{

  $smtp_row=View_Setting_Smtp();

  $mail->Mailer = "smtp";

  $mail->Host=$smtp_row[0];

  $mail->Port=$smtp_row[1];

  if ($smtp_row[4]=="true")

  {

$mail->SMTPAuth=true;

$mail->Username=$smtp_row[2];

$mail->Password=$smtp_row[3];

  }

  else

{

$mail->SMTPAuth=false;

$mail->Username="";

$mail->Password="";   

  }

 

  }

  elseif(isset($setMailSendType) && ($setMailSendType=="sendmail"))

  { 

$mail->Mailer = "sendmail";

$path=View_SendMail_Path();

$mail->Sendmail = $path[0];

}

                               

$mail->From=$row_setting[3];

$mail->FromName = $row_setting[2];         

$mail->ContentType ="text/html";

$mail->AddAddress($from_email);             

$mail->Subject= stripslashes($subject);

$mail->Body = stripslashes($body);

       

  if(!$mail->Send())

{

 

}

else

{

$mail->ClearAddresses();

}

 

}//end of if  if($row_setting[14]!="on")

}//end of double opt in

    } //end of  if

 

}

}//end of "Y"

 

//==================Code for unsubscription==================================

  if($pop_setings[$x][26]=="Y")

    {

      if(($subject_email == $pop_setings[$x][28]) && ($to_email==$pop_setings[$x][27]))

{

$from_name = $header->fromaddress;

    $from_email=$array_header['from']['0']['mailbox'] . "@" . $array_header['from']['0']['host'];

$check1=Check_Email_Existing($pop_setings[$x][1],$from_email);

if($check1!=0)

{

$status=0;

$query="update ".SUBSCRIBERS_TABLE." set `status`=".$status." where campid=".$pop_setings[$x][1]." and EMAIL='".$from_email."'";

$q =db_query($query)or die (db_error());

                        }

            }

    }

 

/////===================code for track bounced mail====================================

if($from_email!=$pop_setings[$x][3])

{

        $pos_matter=$basepath."bounced_mail.php?id=";

//$pos_matter = "<img src='$bouncelink'";

if(strpos($body_email,$pos_matter)===false)

{

//echo "<li>Not found matter";

}

else

  {

$pos = strpos($body_email,$pos_matter) + strlen($pos_matter);

$str = substr($body_email,$pos);

$subscribers_id = substr($str,0,strpos($str,"'"));

        if(is_int($subscribers_id))

{

$bounced_status=5;

$query="update ".SUBSCRIBERS_TABLE." set `status`=".$bounced_status." where campid=".$pop_setings[$x][1]." and id=".$subscribers_id;

$q =db_query($query)or die (db_error());

    }

    }

 

}

 

 

}

}

}

}

// Add here to delete read email

imap_delete($mbox,$y);

// Mark As Deletion

   

 

// Purge email before closing

imap_expunge($mbox);

 

// Connection close

@imap_close($mbox);

 

///////////////////////////////////

 

 

 

 

 

} ?>

 

 

And here is the error I am getting:

 

<br />

<b>Warning</b>:  imap_delete(): supplied argument is not a valid imap resource in

<b>/home/claimyou/public_html/ema/cron.pop3.php</b> on line <b>423</b><br />

<br />

<b>Warning</b>:  imap_expunge(): supplied argument is not a valid imap resource in

<b>/home/claimyou/public_html/ema/cron.pop3.php</b> on line <b>428</b><br />

 

 

The hosting account is running php 5.6.2

 

If anyone can tell me what the issue with this code is -- I would greatly appreciate it.  I simply can't afford to hire a coder to correct it -- I would gladly send the person who helps me some money in another month or so -- I just can't afford it right now so I'm looking for help where ever I can get it.

 

Thank you.

 

Elizabeth Martinez

Link to comment
https://forums.phpfreaks.com/topic/135503-solved-imap_deletephp-issue/
Share on other sites

i must stress this is after a very quick review

 

$y was being used inside the foreach block so i changed to to $m and the delete has also been moved up to inside the check to make sure its set.. this should do the trick..

 

full code below

 

<?php
require_once ('commoninclude.php');
require_once ("class.phpmailer.php");

$mail = new PHPMailer ( );
$pop_setings = Pop_Account_Settings ();
$counter = count ( $pop_setings );
if ($counter !== 0) {
for($x = 0; $x < count ( $pop_setings ); $x ++) {
	$mbox = @imap_open ( $pop_setings [$x] [20], $pop_setings [$x] [21], $pop_setings [$x] [22] );
	if ($mbox !== false) {
		$check = imap_check ( $mbox );
		$totalmessages = $check->Nmsgs;
		for($m = 1; $m <= $totalmessages; $m ++) {
			$header = imap_header ( $mbox, $m );
			if ($header !== false) {
				$subject_email = $header->Subject;
				$body_email = imap_body ( $mbox, $m );
				$body_length = strlen ( $body );
				$array_header = object_to_array ( $header );
				$to_email = $array_header ['to'] ['0'] ['mailbox'] . "@" . $array_header ['to'] ['0'] ['host'];
				if ($pop_setings [$x] [23] == "Y") {
					if (($subject_email == $pop_setings [$x] [25]) && ($to_email == $pop_setings [$x] [24])) {
						$full_name = $header->fromaddress;
						$name_array = explode ( " ", trim ( $full_name ) );
						if ($name_array [0] != "" && $name_array [1] != "" && $name_array [0] != " " && $name_array [1] != " ") {
							$from_name = $name_array [0];
							$last_name = $name_array [1];
						} else {
							$from_name = $full_name;
							$last_name = "";
						}
						$from_email = $array_header ['from'] ['0'] ['mailbox'] . "@" . $array_header ['from'] ['0'] ['host'];
						$check1 = Check_Email_Existing ( $pop_setings [$x] [1], $from_email );
						$row_setting = View_Setting ( $pop_setings [$x] [1] );
						$tracking_links = GetAllTracking_links ( $pop_setings [$x] [1] );
						$cnt = count ( $tracking_links );
						$All_group = GetAllGroupName ( $pop_setings [$x] [1] );
						$campaign_list = Show_Selected_Campaign ( $pop_setings [$x] [1] );
						///////////////////////////////////////////
						if ($check1 == 0) {
							if ($row_setting [10] == "Single") {
								$subs_type = "Email";
								$ip_address = $_SERVER ['REMOTE_ADDR'];
								$sign_up_url = $_SERVER ['HTTP_REFERER'];
								$data1 = "insert into " . SUBSCRIBERS_TABLE . " (campid,name,email,date_of_join,status,subs_type,ip_address,sign_url) values(" . $pop_setings [$x] [1] . ",'" . $from_name . "','" . $from_email . "','" . offset_date () . "',1,'" . $subs_type . "','" . $ip_address . "','" . $sign_up_url . "')";
								$result1 = db_query ( $data1 );
								$getid = "select max(id) from " . SUBSCRIBERS_TABLE . "";
								$q = db_query ( $getid );
								$rsgetid = db_fetch_row ( $q );
								$subs_id = $rsgetid [0];
								/////////////////////////////////////////////////////////////////////////////////             
								//==coding for  remove same mail id if exist in other campaign
								$existing_camp_id = Check_Email_Existing_In_All_Subscribers ( $from_email );
								for($z = 0; $z < count ( $existing_camp_id ); $z ++) {
									$rowsetting_new_camp = View_Setting ( $existing_camp_id [$z] [1] );
									if ($rowsetting_new_camp [18] != "") {
										$camp_name_list = $rowsetting_new_camp [18];
										$camp_array = explode ( ",", $camp_name_list );
										for($y = 0; $y < count ( $camp_array ); $y ++) {
											$new_campid = Show_Campaign_Id ( $camp_array [$y] );
											if ($new_campid == $pop_setings [$x] [1]) {
												$new_status = 0;
												$query = "update " . SUBSCRIBERS_TABLE . " set status=" . $new_status . " where  id = " . $existing_camp_id [$z] [0];
												$q = db_query ( $query ) or die ( db_error () );
											}
										}
									}
								}

								//=====================from here code for  zero delay mail to these subscribers
								$content = Show_Confirm_Message_Campain_Queue ( $pop_setings [$x] [1] );
								if (($content != "") && ($row_setting [14] != "on")) {

									$msgid = $content [0];
									$subject = $content [2];
									$body = $content [3];
									////////////////////////////////////////////////
									/////==modified code for links personalisation==////////
									$read_online = explode ( "#OnlineReadLink(", $body );
									$read_online = explode ( ")#", $read_online [1] );
									$online_text = $read_online [0];

									$link_unsub = explode ( "#UnsubscribeLink[", $body );
									$link_unsub = explode ( "]#", $link_unsub [1] );
									$unsub_text = $link_unsub [0];
									//////================end here================//
									/////////////////////////////////////////////////
									$date = offset_date ();
									$current_date = offset_date ();
									$subject = str_replace ( "#Name#", $from_name, $subject );
									$subject = str_replace ( "#LastName#", $last_name, $subject );
									$subject = str_replace ( "#EmailId#", $from_email, $subject );
									$subject = str_replace ( "#IPAddress#", $ip_address, $subject );
									$subject = str_replace ( "#JoinDate#", $date, $subject );
									$subject = str_replace ( "#SignupUrl#", $sign_up_url, $subject );

									$body = str_replace ( "#Name#", $from_name, $body );
									$body = str_replace ( "#LastName#", $last_name, $body );
									$body = str_replace ( "#EmailId#", $from_email, $body );
									$body = str_replace ( "#IPAddress#", $ip_address, $body );
									$body = str_replace ( "#JoinDate#", $date, $body );
									$body = str_replace ( "#SignupUrl#", $sign_up_url, $body );
									$body = str_replace ( "#CurrentDate#", $current_date, $body );

									for($i = 0; $i <= $cnt - 1; $i ++) {
										$var = $basepath . "getcode.php?id={$tracking_links[$i][3]}&email=#EmailId#";
										$var_new = str_replace ( "#EmailId#", urlencode ( $from_email ), $var );
										$var_link = "<a href='$var_new'>$var_new</a>";
										$body = str_replace ( "#" . $tracking_links [$i] [5] . "#", $var_link, $body );
									}

									for($m = 0; $m < count ( $All_group ); $m ++) //this loop is for group
{
										$random_link_in_group = Select_Random_Link ( $All_group [$m] [0] );
										$total_link = count ( $random_link_in_group );
										$random_link = rand ( 1, $total_link );
										$new_random_link = ($random_link - 1);
										$variable = $basepath . "getcode.php?id={$random_link_in_group[$new_random_link][3]}&email=#EmailId#";
										$variable_new = str_replace ( "#EmailId#", urlencode ( $from_email ), $variable );
										$variable_link = "<a href='$variable_new'>$variable_new</a>";
										$body = str_replace ( "#" . $All_group [$m] [2] . "#", $variable_link, $body );
									}

									for($p = 0; $p < count ( $campaign_list ); $p ++) {
										$upgrade = $basepath . "upgrade.php?id=" . $subs_id . "&cid=" . $campaign_list [$p] [0] . "&em=" . urlencode ( $from_email );
										$upgrade_new = "<a href='$upgrade'>$upgrade</a>";
										$body = str_replace ( "#" . $campaign_list [$p] [1] . "#", $upgrade_new, $body );
									}
									/////////////////////////////////////////////////////////
									//==This code is for message display according to type==//
									$contenttype = $content [7];
									$total_msg_read = $basepath . "total_message_read.php?id=" . $msgid . "&msg_methode=queue&email_id=" . $from_email . "&campid=" . $pop_setings [$x] [1];
									$total_read = "<img src='$total_msg_read' width'0' height='0'>";
									$line_break = "<br>";
									if ($contenttype == "text") {

										$unsubscribe_url = $unsub_text . "::" . $basepath . "unsubscribe.php?id=" . $subs_id . "&cid=" . md5 ( $from_email . $pop_setings [$x] [1] );
										$server_message = $online_text . "::" . $basepath . "server.php?id=" . $subs_id . "&campid=" . $pop_setings [$x] [1] . "&msgmtd=queue&msgid=" . $msgid;
										$body = str_replace ( "#UnsubscribeLink[" . $unsub_text . "]#", $unsubscribe_url, $body );
										$body = str_replace ( "#OnlineReadLink(" . $online_text . ")#", $server_message, $body );
										$confirm_message = url2link ( $body ) . " " . $line_break . " " . $total_read;
									} 

									elseif ($contenttype == "html") {

										$var = $basepath . "unsubscribe.php?id=" . $subs_id . "&cid=" . md5 ( $from_email . $pop_setings [$x] [1] );
										$var_msg = $basepath . "server.php?id=" . $subs_id . "&campid=" . $pop_setings [$x] [1] . "&msgmtd=queue&msgid=" . $msgid;

										$unsubscribe_url = "<a href='$var' title='Click Here To unsubscribe us'>" . $unsub_text . "</a>";
										$server_message = "<a href='$var_msg' title='If You are not able to read this email properly then click here to read this email online'>" . $online_text . "</a>";

										$body = str_replace ( "#UnsubscribeLink[" . $unsub_text . "]#", $unsubscribe_url, $body );
										$body = str_replace ( "#OnlineReadLink(" . $online_text . ")#", $server_message, $body );
										$confirm_message = $body . " " . $line_break . " " . $total_read;
									}
									/////////===End code==//////////////////
									////////////////////////////////////////////////////////
									////===============================Code  for email delievery=============================
									//=======================================================================================                           
									$mail_type_settings = View_Priority_Settings ();
									$mail->Priority = $mail_type_settings [0];
									$setMailSendType = $mail_type_settings [1];
									$mail->CharSet = $mail_type_settings [5];

									if (isset ( $setMailSendType ) && ($setMailSendType == "smtp")) {
										$smtp_row = View_Setting_Smtp ();
										$mail->Mailer = "smtp";
										$mail->Host = $smtp_row [0];
										$mail->Port = $smtp_row [1];

										if ($smtp_row [4] == "true") {
											$mail->SMTPAuth = true;
											$mail->Username = $smtp_row [2];
											$mail->Password = $smtp_row [3];
										} else {
											$mail->SMTPAuth = false;
											$mail->Username = "";
											$mail->Password = "";
										}

									} elseif (isset ( $setMailSendType ) && ($setMailSendType == "sendmail")) {
										$mail->Mailer = "sendmail";
										$path = View_SendMail_Path ();
										$mail->Sendmail = $path [0];
									}

									$dir = "uploadedimages/";
									$attfile = $dir . $content [4];
									$mail->From = $row_setting [3];
									$mail->FromName = $row_setting [2]; //fromname means sender Email Id
									$mail->ContentType = "text/html";
									$mail->AddAddress ( $from_email ); // Reciepients Id
									$mail->Subject = stripslashes ( $subject );
									$mail->Body = stripslashes ( $confirm_message );
									$mail->AddAttachment ( $attfile );
									if ($mail->Send ()) {
										$sending_way = "queue";
										Save_Sent_Message ( $pop_setings [$x] [1], $subs_id, $msgid, $from_email, $sending_way );
										$mail->ClearAddresses ();
									}

									//=====================Admin report=======================
									if ($row_setting [7] == "on") {
										Confirmation_Mail_to_Admin ( $pop_setings [$x] [1], $from_name, $last_name, $from_email, $ip_address, $sign_up_url, $row_setting [3], $row_setting [2], $row_setting [8] );
									}
								}
							} else //end of if of single opt_in if loop
//start of double opt in type
							{
								$subs_type = "Email";
								$ip_address = $_SERVER ['REMOTE_ADDR'];
								$sign_up_url = $_SERVER ['HTTP_REFERER'];
								$data1 = "insert into " . SUBSCRIBERS_TABLE . " (campid,name,email,date_of_join,status,subs_type,ip_address,sign_url,last_name) values(" . $pop_setings [$x] [1] . ",'" . $from_name . "','" . $from_email . "','" . offset_date () . "',0,'" . $subs_type . "','" . $ip_address . "','" . $sign_up_url . "','" . $last_name . "')";
								$result1 = db_query ( $data1 );
								$subs_id = db_insert_id ();
								$date = offset_date ();
								// $subs_details=View_Subscribers_details_By_mail_campid($from_email,$pop_setings[$x][1]);
								//   $subs_id=$subs_details[0][0];
								//   $date=$subs_details[0][4];


								/////////////////////////////////////////////////////////////////////////////////             
								//==coding for  remove same mail id if exist in other campaign
								$existing_camp_id = Check_Email_Existing_In_All_Subscribers ( $from_email );
								for($z = 0; $z < count ( $existing_camp_id ); $z ++) {
									$rowsetting_new_camp = View_Setting ( $existing_camp_id [$z] [1] );
									if ($rowsetting_new_camp [18] != "") {
										$camp_name_list = $rowsetting_new_camp [18];
										$camp_array = explode ( ",", $camp_name_list );
										for($y = 0; $y < count ( $camp_array ); $y ++) {
											$new_campid = Show_Campaign_Id ( $camp_array [$y] );
											if ($new_campid == $pop_setings [$x] [1]) {
												$new_status = 0;
												$query = "update " . SUBSCRIBERS_TABLE . " set status=" . $new_status . " where  id = " . $existing_camp_id [$z] [0];
												$q = db_query ( $query ) or die ( db_error () );
											}
										}
									}
								}
								/////////////////////////////////////////////////////////////////////////


								if ($row_setting [14] != "on") {

									$verify_lk = $basepath . "confirm.php?id=" . $subs_id . "&cid=" . $pop_setings [$x] [1] . "&em=" . urlencode ( $from_email );
									$verifylink = "<a href='$verify_lk'>$verify_lk</a>";
									$subject = $row_setting [12];
									$body = $row_setting [13];
									$subject = str_replace ( "#Name#", $from_name, $subject );
									$subject = str_replace ( "#LastName#", $last_name, $subject );
									$subject = str_replace ( "#EmailId#", $from_email, $subject );
									$subject = str_replace ( "#IPAddress#", $ip_address, $subject );
									$subject = str_replace ( "#JoinDate#", $date, $subject );
									$subject = str_replace ( "#SignupUrl#", $sign_up_url, $subject );
									$subject = str_replace ( "#VerifyLink#", $verifylink, $subject );

									$body = str_replace ( "#Name#", $from_email, $body );
									$body = str_replace ( "#LastName#", $last_name, $body );
									$body = str_replace ( "#EmailId#", $from_email, $body );
									$body = str_replace ( "#IPAddress#", $ip_address, $body );
									$body = str_replace ( "#JoinDate#", $date, $body );
									$body = str_replace ( "#SignupUrl#", $sign_up_url, $body );
									$body = str_replace ( "#VerifyLink#", $verifylink, $body );

									for($i = 0; $i <= $cnt - 1; $i ++) {
										$var = $basepath . "getcode.php?id={$tracking_links[$i][3]}&email=#EmailId#";
										$var_new = str_replace ( "#EmailId#", urlencode ( $from_email ), $var );
										$var_link = "<a href='$var_new'>$var_new</a>";
										$body = str_replace ( "#" . $tracking_links [$i] [5] . "#", $var_link, $body );
									}

									for($m = 0; $m < count ( $All_group ); $m ++) //this loop is for group
{
										$random_link_in_group = Select_Random_Link ( $All_group [$m] [0] );
										$total_link = count ( $random_link_in_group );
										$random_link = rand ( 1, $total_link );
										$new_random_link = ($random_link - 1);
										$variable = $basepath . "getcode.php?id={$random_link_in_group[$new_random_link][3]}&email=#EmailId#";
										$variable_new = str_replace ( "#EmailId#", urlencode ( $from_email ), $variable );
										$variable_link = "<a href='$variable_new'>$variable_new</a>";
										$body = str_replace ( "#" . $All_group [$m] [2] . "#", $variable_link, $body );
									}
									////////////////////////////////////////////////////////////////////////////////////////////
									////===============================Code  for email delievery=============================
									//=======================================================================================                           
									$mail_type_settings = View_Priority_Settings ();
									$mail->Priority = $mail_type_settings [0];
									$setMailSendType = $mail_type_settings [1];
									$mail->CharSet = $mail_type_settings [5];
									if (isset ( $setMailSendType ) && ($setMailSendType == "smtp")) {
										$smtp_row = View_Setting_Smtp ();
										$mail->Mailer = "smtp";
										$mail->Host = $smtp_row [0];
										$mail->Port = $smtp_row [1];
										if ($smtp_row [4] == "true") {
											$mail->SMTPAuth = true;
											$mail->Username = $smtp_row [2];
											$mail->Password = $smtp_row [3];
										} else {
											$mail->SMTPAuth = false;
											$mail->Username = "";
											$mail->Password = "";
										}

									} elseif (isset ( $setMailSendType ) && ($setMailSendType == "sendmail")) {
										$mail->Mailer = "sendmail";
										$path = View_SendMail_Path ();
										$mail->Sendmail = $path [0];
									}

									$mail->From = $row_setting [3];
									$mail->FromName = $row_setting [2];
									$mail->ContentType = "text/html";
									$mail->AddAddress ( $from_email );
									$mail->Subject = stripslashes ( $subject );
									$mail->Body = stripslashes ( $body );

									if (! $mail->Send ()) {

									} else {
										$mail->ClearAddresses ();
									}

								} //end of if  if($row_setting[14]!="on")
							} //end of double opt in
						} //end of  if


					}
				} //end of "Y"


				//==================Code for unsubscription==================================
				if ($pop_setings [$x] [26] == "Y") {
					if (($subject_email == $pop_setings [$x] [28]) && ($to_email == $pop_setings [$x] [27])) {
						$from_name = $header->fromaddress;
						$from_email = $array_header ['from'] ['0'] ['mailbox'] . "@" . $array_header ['from'] ['0'] ['host'];
						$check1 = Check_Email_Existing ( $pop_setings [$x] [1], $from_email );
						if ($check1 != 0) {
							$status = 0;
							$query = "update " . SUBSCRIBERS_TABLE . " set `status`=" . $status . " where campid=" . $pop_setings [$x] [1] . " and EMAIL='" . $from_email . "'";
							$q = db_query ( $query ) or die ( db_error () );
						}
					}
				}

				/////===================code for track bounced mail====================================                  
				if ($from_email != $pop_setings [$x] [3]) {
					$pos_matter = $basepath . "bounced_mail.php?id=";
					//$pos_matter = "<img src='$bouncelink'";
					if (strpos ( $body_email, $pos_matter ) === false) {
						//echo "<li>Not found matter";
					} else {
						$pos = strpos ( $body_email, $pos_matter ) + strlen ( $pos_matter );
						$str = substr ( $body_email, $pos );
						$subscribers_id = substr ( $str, 0, strpos ( $str, "'" ) );
						if (is_int ( $subscribers_id )) {
							$bounced_status = 5;
							$query = "update " . SUBSCRIBERS_TABLE . " set `status`=" . $bounced_status . " where campid=" . $pop_setings [$x] [1] . " and id=" . $subscribers_id;
							$q = db_query ( $query ) or die ( db_error () );
						}
					}

				}

			}
		}
	if($mbox)
	{
		// Add here to delete read email
		imap_delete ( $mbox, $m );
		// Mark As Deletion


		// Purge email before closing
		imap_expunge ( $mbox );

		// Connection close
		@imap_close ( $mbox );
	}
	}
}

///////////////////////////////////
}
?> 

Please forgive me for not posting my code correctly - I should have read more of the forum before I posted - I know better.

 

Thank you so much for your quick response.  That change got rid of the error message -- but the e-mails aren't being deleted. 

 

Any ideas on how to get all the messages in the inbox deleted when cron.pop3.php is run?  The imap_delete... imap_expunge was supposed to do that - at least that is what I thought.

 

I do appreciate your time and assistance.

 

Elizabeth Martinez

Okay i have updated the code

 

Heres a snippet

i move the delet to the correct place BUT as your clearing all tagging all of them and then deleting its a little slower that i you would like to i updated it to purge all at once..

				
			}
			/*this should be here*/
			// Add here to delete read email
			#imap_delete ( $mbox, $m ); //Removed
			// Mark As Deletion
		}
		/*But this will work better*/
		//clear out an entire mailbox.
		imap_delete($mbox,'1:*'); //Added to do a full purge!
		// Purge email before closing
		imap_expunge ( $mbox );

		// Connection close
		@imap_close ( $mbox );
	}

 

EDIT: and and your welcome and welcome to phpfreaks

 

Full code below

 

<?php
require_once ('commoninclude.php');
require_once ("class.phpmailer.php");

$mail = new PHPMailer ( );
$pop_setings = Pop_Account_Settings ();
$counter = count ( $pop_setings );
if ($counter !== 0) {
for($x = 0; $x < count ( $pop_setings ); $x ++) {
	$mbox = @imap_open ( $pop_setings [$x] [20], $pop_setings [$x] [21], $pop_setings [$x] [22] );
	if ($mbox !== false) {
		$check = imap_check ( $mbox );
		$totalmessages = $check->Nmsgs;
		for($m = 1; $m <= $totalmessages; $m ++) {
			$header = imap_header ( $mbox, $m );
			if ($header !== false) {
				$subject_email = $header->Subject;
				$body_email = imap_body ( $mbox, $m );
				$body_length = strlen ( $body );
				$array_header = object_to_array ( $header );
				$to_email = $array_header ['to'] ['0'] ['mailbox'] . "@" . $array_header ['to'] ['0'] ['host'];
				if ($pop_setings [$x] [23] == "Y") {
					if (($subject_email == $pop_setings [$x] [25]) && ($to_email == $pop_setings [$x] [24])) {
						$full_name = $header->fromaddress;
						$name_array = explode ( " ", trim ( $full_name ) );
						if ($name_array [0] != "" && $name_array [1] != "" && $name_array [0] != " " && $name_array [1] != " ") {
							$from_name = $name_array [0];
							$last_name = $name_array [1];
						} else {
							$from_name = $full_name;
							$last_name = "";
						}
						$from_email = $array_header ['from'] ['0'] ['mailbox'] . "@" . $array_header ['from'] ['0'] ['host'];
						$check1 = Check_Email_Existing ( $pop_setings [$x] [1], $from_email );
						$row_setting = View_Setting ( $pop_setings [$x] [1] );
						$tracking_links = GetAllTracking_links ( $pop_setings [$x] [1] );
						$cnt = count ( $tracking_links );
						$All_group = GetAllGroupName ( $pop_setings [$x] [1] );
						$campaign_list = Show_Selected_Campaign ( $pop_setings [$x] [1] );
						///////////////////////////////////////////
						if ($check1 == 0) {
							if ($row_setting [10] == "Single") {
								$subs_type = "Email";
								$ip_address = $_SERVER ['REMOTE_ADDR'];
								$sign_up_url = $_SERVER ['HTTP_REFERER'];
								$data1 = "insert into " . SUBSCRIBERS_TABLE . " (campid,name,email,date_of_join,status,subs_type,ip_address,sign_url) values(" . $pop_setings [$x] [1] . ",'" . $from_name . "','" . $from_email . "','" . offset_date () . "',1,'" . $subs_type . "','" . $ip_address . "','" . $sign_up_url . "')";
								$result1 = db_query ( $data1 );
								$getid = "select max(id) from " . SUBSCRIBERS_TABLE . "";
								$q = db_query ( $getid );
								$rsgetid = db_fetch_row ( $q );
								$subs_id = $rsgetid [0];
								/////////////////////////////////////////////////////////////////////////////////             
								//==coding for  remove same mail id if exist in other campaign
								$existing_camp_id = Check_Email_Existing_In_All_Subscribers ( $from_email );
								for($z = 0; $z < count ( $existing_camp_id ); $z ++) {
									$rowsetting_new_camp = View_Setting ( $existing_camp_id [$z] [1] );
									if ($rowsetting_new_camp [18] != "") {
										$camp_name_list = $rowsetting_new_camp [18];
										$camp_array = explode ( ",", $camp_name_list );
										for($y = 0; $y < count ( $camp_array ); $y ++) {
											$new_campid = Show_Campaign_Id ( $camp_array [$y] );
											if ($new_campid == $pop_setings [$x] [1]) {
												$new_status = 0;
												$query = "update " . SUBSCRIBERS_TABLE . " set status=" . $new_status . " where  id = " . $existing_camp_id [$z] [0];
												$q = db_query ( $query ) or die ( db_error () );
											}
										}
									}
								}

								//=====================from here code for  zero delay mail to these subscribers
								$content = Show_Confirm_Message_Campain_Queue ( $pop_setings [$x] [1] );
								if (($content != "") && ($row_setting [14] != "on")) {

									$msgid = $content [0];
									$subject = $content [2];
									$body = $content [3];
									////////////////////////////////////////////////
									/////==modified code for links personalisation==////////
									$read_online = explode ( "#OnlineReadLink(", $body );
									$read_online = explode ( ")#", $read_online [1] );
									$online_text = $read_online [0];

									$link_unsub = explode ( "#UnsubscribeLink[", $body );
									$link_unsub = explode ( "]#", $link_unsub [1] );
									$unsub_text = $link_unsub [0];
									//////================end here================//
									/////////////////////////////////////////////////
									$date = offset_date ();
									$current_date = offset_date ();
									$subject = str_replace ( "#Name#", $from_name, $subject );
									$subject = str_replace ( "#LastName#", $last_name, $subject );
									$subject = str_replace ( "#EmailId#", $from_email, $subject );
									$subject = str_replace ( "#IPAddress#", $ip_address, $subject );
									$subject = str_replace ( "#JoinDate#", $date, $subject );
									$subject = str_replace ( "#SignupUrl#", $sign_up_url, $subject );

									$body = str_replace ( "#Name#", $from_name, $body );
									$body = str_replace ( "#LastName#", $last_name, $body );
									$body = str_replace ( "#EmailId#", $from_email, $body );
									$body = str_replace ( "#IPAddress#", $ip_address, $body );
									$body = str_replace ( "#JoinDate#", $date, $body );
									$body = str_replace ( "#SignupUrl#", $sign_up_url, $body );
									$body = str_replace ( "#CurrentDate#", $current_date, $body );

									for($i = 0; $i <= $cnt - 1; $i ++) {
										$var = $basepath . "getcode.php?id={$tracking_links[$i][3]}&email=#EmailId#";
										$var_new = str_replace ( "#EmailId#", urlencode ( $from_email ), $var );
										$var_link = "<a href='$var_new'>$var_new</a>";
										$body = str_replace ( "#" . $tracking_links [$i] [5] . "#", $var_link, $body );
									}

									for($m = 0; $m < count ( $All_group ); $m ++) //this loop is for group
{
										$random_link_in_group = Select_Random_Link ( $All_group [$m] [0] );
										$total_link = count ( $random_link_in_group );
										$random_link = rand ( 1, $total_link );
										$new_random_link = ($random_link - 1);
										$variable = $basepath . "getcode.php?id={$random_link_in_group[$new_random_link][3]}&email=#EmailId#";
										$variable_new = str_replace ( "#EmailId#", urlencode ( $from_email ), $variable );
										$variable_link = "<a href='$variable_new'>$variable_new</a>";
										$body = str_replace ( "#" . $All_group [$m] [2] . "#", $variable_link, $body );
									}

									for($p = 0; $p < count ( $campaign_list ); $p ++) {
										$upgrade = $basepath . "upgrade.php?id=" . $subs_id . "&cid=" . $campaign_list [$p] [0] . "&em=" . urlencode ( $from_email );
										$upgrade_new = "<a href='$upgrade'>$upgrade</a>";
										$body = str_replace ( "#" . $campaign_list [$p] [1] . "#", $upgrade_new, $body );
									}
									/////////////////////////////////////////////////////////
									//==This code is for message display according to type==//
									$contenttype = $content [7];
									$total_msg_read = $basepath . "total_message_read.php?id=" . $msgid . "&msg_methode=queue&email_id=" . $from_email . "&campid=" . $pop_setings [$x] [1];
									$total_read = "<img src='$total_msg_read' width'0' height='0'>";
									$line_break = "<br>";
									if ($contenttype == "text") {

										$unsubscribe_url = $unsub_text . "::" . $basepath . "unsubscribe.php?id=" . $subs_id . "&cid=" . md5 ( $from_email . $pop_setings [$x] [1] );
										$server_message = $online_text . "::" . $basepath . "server.php?id=" . $subs_id . "&campid=" . $pop_setings [$x] [1] . "&msgmtd=queue&msgid=" . $msgid;
										$body = str_replace ( "#UnsubscribeLink[" . $unsub_text . "]#", $unsubscribe_url, $body );
										$body = str_replace ( "#OnlineReadLink(" . $online_text . ")#", $server_message, $body );
										$confirm_message = url2link ( $body ) . " " . $line_break . " " . $total_read;
									} 

									elseif ($contenttype == "html") {

										$var = $basepath . "unsubscribe.php?id=" . $subs_id . "&cid=" . md5 ( $from_email . $pop_setings [$x] [1] );
										$var_msg = $basepath . "server.php?id=" . $subs_id . "&campid=" . $pop_setings [$x] [1] . "&msgmtd=queue&msgid=" . $msgid;

										$unsubscribe_url = "<a href='$var' title='Click Here To unsubscribe us'>" . $unsub_text . "</a>";
										$server_message = "<a href='$var_msg' title='If You are not able to read this email properly then click here to read this email online'>" . $online_text . "</a>";

										$body = str_replace ( "#UnsubscribeLink[" . $unsub_text . "]#", $unsubscribe_url, $body );
										$body = str_replace ( "#OnlineReadLink(" . $online_text . ")#", $server_message, $body );
										$confirm_message = $body . " " . $line_break . " " . $total_read;
									}
									/////////===End code==//////////////////
									////////////////////////////////////////////////////////
									////===============================Code  for email delievery=============================
									//=======================================================================================                           
									$mail_type_settings = View_Priority_Settings ();
									$mail->Priority = $mail_type_settings [0];
									$setMailSendType = $mail_type_settings [1];
									$mail->CharSet = $mail_type_settings [5];

									if (isset ( $setMailSendType ) && ($setMailSendType == "smtp")) {
										$smtp_row = View_Setting_Smtp ();
										$mail->Mailer = "smtp";
										$mail->Host = $smtp_row [0];
										$mail->Port = $smtp_row [1];

										if ($smtp_row [4] == "true") {
											$mail->SMTPAuth = true;
											$mail->Username = $smtp_row [2];
											$mail->Password = $smtp_row [3];
										} else {
											$mail->SMTPAuth = false;
											$mail->Username = "";
											$mail->Password = "";
										}

									} elseif (isset ( $setMailSendType ) && ($setMailSendType == "sendmail")) {
										$mail->Mailer = "sendmail";
										$path = View_SendMail_Path ();
										$mail->Sendmail = $path [0];
									}

									$dir = "uploadedimages/";
									$attfile = $dir . $content [4];
									$mail->From = $row_setting [3];
									$mail->FromName = $row_setting [2]; //fromname means sender Email Id
									$mail->ContentType = "text/html";
									$mail->AddAddress ( $from_email ); // Reciepients Id
									$mail->Subject = stripslashes ( $subject );
									$mail->Body = stripslashes ( $confirm_message );
									$mail->AddAttachment ( $attfile );
									if ($mail->Send ()) {
										$sending_way = "queue";
										Save_Sent_Message ( $pop_setings [$x] [1], $subs_id, $msgid, $from_email, $sending_way );
										$mail->ClearAddresses ();
									}

									//=====================Admin report=======================
									if ($row_setting [7] == "on") {
										Confirmation_Mail_to_Admin ( $pop_setings [$x] [1], $from_name, $last_name, $from_email, $ip_address, $sign_up_url, $row_setting [3], $row_setting [2], $row_setting [8] );
									}
								}
							} else //end of if of single opt_in if loop
//start of double opt in type
							{
								$subs_type = "Email";
								$ip_address = $_SERVER ['REMOTE_ADDR'];
								$sign_up_url = $_SERVER ['HTTP_REFERER'];
								$data1 = "insert into " . SUBSCRIBERS_TABLE . " (campid,name,email,date_of_join,status,subs_type,ip_address,sign_url,last_name) values(" . $pop_setings [$x] [1] . ",'" . $from_name . "','" . $from_email . "','" . offset_date () . "',0,'" . $subs_type . "','" . $ip_address . "','" . $sign_up_url . "','" . $last_name . "')";
								$result1 = db_query ( $data1 );
								$subs_id = db_insert_id ();
								$date = offset_date ();
								// $subs_details=View_Subscribers_details_By_mail_campid($from_email,$pop_setings[$x][1]);
								//   $subs_id=$subs_details[0][0];
								//   $date=$subs_details[0][4];


								/////////////////////////////////////////////////////////////////////////////////             
								//==coding for  remove same mail id if exist in other campaign
								$existing_camp_id = Check_Email_Existing_In_All_Subscribers ( $from_email );
								for($z = 0; $z < count ( $existing_camp_id ); $z ++) {
									$rowsetting_new_camp = View_Setting ( $existing_camp_id [$z] [1] );
									if ($rowsetting_new_camp [18] != "") {
										$camp_name_list = $rowsetting_new_camp [18];
										$camp_array = explode ( ",", $camp_name_list );
										for($y = 0; $y < count ( $camp_array ); $y ++) {
											$new_campid = Show_Campaign_Id ( $camp_array [$y] );
											if ($new_campid == $pop_setings [$x] [1]) {
												$new_status = 0;
												$query = "update " . SUBSCRIBERS_TABLE . " set status=" . $new_status . " where  id = " . $existing_camp_id [$z] [0];
												$q = db_query ( $query ) or die ( db_error () );
											}
										}
									}
								}
								/////////////////////////////////////////////////////////////////////////


								if ($row_setting [14] != "on") {

									$verify_lk = $basepath . "confirm.php?id=" . $subs_id . "&cid=" . $pop_setings [$x] [1] . "&em=" . urlencode ( $from_email );
									$verifylink = "<a href='$verify_lk'>$verify_lk</a>";
									$subject = $row_setting [12];
									$body = $row_setting [13];
									$subject = str_replace ( "#Name#", $from_name, $subject );
									$subject = str_replace ( "#LastName#", $last_name, $subject );
									$subject = str_replace ( "#EmailId#", $from_email, $subject );
									$subject = str_replace ( "#IPAddress#", $ip_address, $subject );
									$subject = str_replace ( "#JoinDate#", $date, $subject );
									$subject = str_replace ( "#SignupUrl#", $sign_up_url, $subject );
									$subject = str_replace ( "#VerifyLink#", $verifylink, $subject );

									$body = str_replace ( "#Name#", $from_email, $body );
									$body = str_replace ( "#LastName#", $last_name, $body );
									$body = str_replace ( "#EmailId#", $from_email, $body );
									$body = str_replace ( "#IPAddress#", $ip_address, $body );
									$body = str_replace ( "#JoinDate#", $date, $body );
									$body = str_replace ( "#SignupUrl#", $sign_up_url, $body );
									$body = str_replace ( "#VerifyLink#", $verifylink, $body );

									for($i = 0; $i <= $cnt - 1; $i ++) {
										$var = $basepath . "getcode.php?id={$tracking_links[$i][3]}&email=#EmailId#";
										$var_new = str_replace ( "#EmailId#", urlencode ( $from_email ), $var );
										$var_link = "<a href='$var_new'>$var_new</a>";
										$body = str_replace ( "#" . $tracking_links [$i] [5] . "#", $var_link, $body );
									}

									for($m = 0; $m < count ( $All_group ); $m ++) //this loop is for group
{
										$random_link_in_group = Select_Random_Link ( $All_group [$m] [0] );
										$total_link = count ( $random_link_in_group );
										$random_link = rand ( 1, $total_link );
										$new_random_link = ($random_link - 1);
										$variable = $basepath . "getcode.php?id={$random_link_in_group[$new_random_link][3]}&email=#EmailId#";
										$variable_new = str_replace ( "#EmailId#", urlencode ( $from_email ), $variable );
										$variable_link = "<a href='$variable_new'>$variable_new</a>";
										$body = str_replace ( "#" . $All_group [$m] [2] . "#", $variable_link, $body );
									}
									////////////////////////////////////////////////////////////////////////////////////////////
									////===============================Code  for email delievery=============================
									//=======================================================================================                           
									$mail_type_settings = View_Priority_Settings ();
									$mail->Priority = $mail_type_settings [0];
									$setMailSendType = $mail_type_settings [1];
									$mail->CharSet = $mail_type_settings [5];
									if (isset ( $setMailSendType ) && ($setMailSendType == "smtp")) {
										$smtp_row = View_Setting_Smtp ();
										$mail->Mailer = "smtp";
										$mail->Host = $smtp_row [0];
										$mail->Port = $smtp_row [1];
										if ($smtp_row [4] == "true") {
											$mail->SMTPAuth = true;
											$mail->Username = $smtp_row [2];
											$mail->Password = $smtp_row [3];
										} else {
											$mail->SMTPAuth = false;
											$mail->Username = "";
											$mail->Password = "";
										}

									} elseif (isset ( $setMailSendType ) && ($setMailSendType == "sendmail")) {
										$mail->Mailer = "sendmail";
										$path = View_SendMail_Path ();
										$mail->Sendmail = $path [0];
									}

									$mail->From = $row_setting [3];
									$mail->FromName = $row_setting [2];
									$mail->ContentType = "text/html";
									$mail->AddAddress ( $from_email );
									$mail->Subject = stripslashes ( $subject );
									$mail->Body = stripslashes ( $body );

									if (! $mail->Send ()) {

									} else {
										$mail->ClearAddresses ();
									}

								} //end of if  if($row_setting[14]!="on")
							} //end of double opt in
						} //end of  if


					}
				} //end of "Y"


				//==================Code for unsubscription==================================
				if ($pop_setings [$x] [26] == "Y") {
					if (($subject_email == $pop_setings [$x] [28]) && ($to_email == $pop_setings [$x] [27])) {
						$from_name = $header->fromaddress;
						$from_email = $array_header ['from'] ['0'] ['mailbox'] . "@" . $array_header ['from'] ['0'] ['host'];
						$check1 = Check_Email_Existing ( $pop_setings [$x] [1], $from_email );
						if ($check1 != 0) {
							$status = 0;
							$query = "update " . SUBSCRIBERS_TABLE . " set `status`=" . $status . " where campid=" . $pop_setings [$x] [1] . " and EMAIL='" . $from_email . "'";
							$q = db_query ( $query ) or die ( db_error () );
						}
					}
				}

				/////===================code for track bounced mail====================================                  
				if ($from_email != $pop_setings [$x] [3]) {
					$pos_matter = $basepath . "bounced_mail.php?id=";
					//$pos_matter = "<img src='$bouncelink'";
					if (strpos ( $body_email, $pos_matter ) === false) {
						//echo "<li>Not found matter";
					} else {
						$pos = strpos ( $body_email, $pos_matter ) + strlen ( $pos_matter );
						$str = substr ( $body_email, $pos );
						$subscribers_id = substr ( $str, 0, strpos ( $str, "'" ) );
						if (is_int ( $subscribers_id )) {
							$bounced_status = 5;
							$query = "update " . SUBSCRIBERS_TABLE . " set `status`=" . $bounced_status . " where campid=" . $pop_setings [$x] [1] . " and id=" . $subscribers_id;
							$q = db_query ( $query ) or die ( db_error () );
						}
					}

				}

			}
			/*this should be here*/
			// Add here to delete read email
			#imap_delete ( $mbox, $m ); //Removed
			// Mark As Deletion
		}
		/*But this will work better*/
		//clear out an entire mailbox.
		imap_delete($mbox,'1:*'); //Added to do a full purge!
		// Purge email before closing
		imap_expunge ( $mbox );

		// Connection close
		@imap_close ( $mbox );
	}
}

///////////////////////////////////
}
?> 

Ok, I'm marking the topic solved because the error is gone adn I've now realized there is some other issue with a setting in the autoresponder because the cron job file isn't even checking the e-mail account.

 

Thank you very much for the help, I really appreciate it.

 

Elizabeth Martinez

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.