Jump to content

Mailer not mailing, absolutely no errors visible.


Greywacke

Recommended Posts

hi,quite hard debugging this kind of thing - i can't seem to find the problem anywhere 0o. this is the manual mailer of statements, via ajax. absolutely no mails are being sent.it is called from the client by:

makeRequest("POST", "scripts/ajax_transactions.php?q=2&s="+s+"&f="+f+"&t="+t, poststr);

it returns a reload of the information. does not seem to perform the switch case for $q in the php.here is the php xml generator:

<?php/*TRANSACTION MANAGER AJAX XML RESPONSEVersion 2.2.4*///set_time_limit(0);include("../includes/content/dwtphovu_f3rr37y.php");$q = $_GET["q"];if (is_numeric($q)) {	if ($q > 1 || $q < 0) {		$q = 0;	}} else {	$q = 0;}$s = $_GET["s"];if (!is_numeric($s)) {	$s = 0;}$f = $_GET["f"];if (!strtotime(date($f))) {	$f = date("Y-m-01 00:00:00");}$t = $_GET["t"];if (!strtotime(date($t))) {	$t = date("Y-m-t 23:59:59");}include('../includes/statistical/timezones/class-timezone-conversion.php');   // Include timezone conversion classfunction convert_tz($timestamp, $timezone) {	// convert local datetime to SAST (South African Standard Time)	$tz = new TimezoneConversion();		// Create TimezoneConversion Object	$tz->setProperty('DateTime', $timestamp);	// Set local 'DateTime' to convert	$tz->setProperty('Timezone', $timezone);	// Set Timezone Convert To	return $tz->convertDateTime();		// Get SAST Timestamp}$limit = "MANUAL";$now = getdate(strtotime(convert_tz(date("Y-m-d H:i:s", time()),"SAST")));$fs = strtotime(date("Y-m-1 00:00:00",mktime(0,0,0,$now["mon"]-3,1,$now["year"])));$fl = strtotime(date("Y-m-1 00:00:00",mktime(0,0,0,$now["mon"],1,$now["year"])));$ts = strtotime(date("Y-m-t 23:59:59",mktime(23,59,59,$now["mon"]+1,0,$now["year"])));$tl = strtotime(date("Y-m-t 23:59:59",mktime(23,59,59,$now["mon"]-2,0,$now["year"])));function getrecords($arr) {	//if supplier id, >= from and <= to dates available create constraints	// ".(($numargs>0)?" WHERE ":"").join(" AND ",$arg_list)."	$sql = "SELECT * FROM 8_transactions".((count($arr)>0)?" WHERE ".join(" AND ",$arr):"")." ORDER BY bigint_TransactionID DESC;";	$result = mysql_query_errors($sql , $conn , __FILE__ , __LINE__ );	if ($result) {		while ($row = mysql_fetch_array($result)) {			echo "	<transaction>\n";			echo "		<transactionid>" . $row["bigint_TransactionID"] . "</transactionid>\n";			echo "		<transactionevent>" . xmlentities($row["text_TransactionEvent"]) . "</transactionevent>\n";			if ($row["bigint_LeadID"]>0) {				$sql1 = "SELECT * FROM 6_serviceleads JOIN (5_suppliers,2_servicescatalogue,1_regions) ON (6_serviceleads.bigint_SupplierID = 5_suppliers.bigint_SupplierID AND 6_serviceleads.bigint_ServiceID = 2_servicescatalogue.bigint_ServiceID AND 6_serviceleads.bigint_RegionID = 1_regions.bigint_RegionID) WHERE bigint_LeadID = ".$row["bigint_LeadID"].";";				$result1 = mysql_query_errors($sql1 , $conn , __FILE__ , __LINE__ );				if ($row1 = mysql_fetch_array($result1)) {					$attr = split("<br />",$row1["text_LeadAttributes"]);					foreach ($attr as $value) {						$val = split(" = ",$value);						if (stristr($val[0],"product")) { $req = trim($val[1]); }						elseif (stristr($val[0],"make_model")) { $mak = trim($val[1]); }						elseif (stristr($val[0],"style")) { $stl = trim($val[1]); }					}					if (strlen($req)==0) { $req = $mak." ".$stl; }					echo "		<makemodelstyle>" . xmlentities($req) . "</makemodelstyle>\n";					echo "		<transactionconsumer>" . xmlentities($row1["text_Consumer"]) . "</transactionconsumer>\n";					echo "		<transactionservice>" . xmlentities($row1["text_ServiceDescription"]) . "</transactionservice>\n";					echo "		<transactionregion>" . xmlentities($row1["text_RegionDescription"]) . "</transactionregion>\n";				}			}			echo "		<transactionamount>" . $row["bigint_TransactionAmount"] . "</transactionamount>\n";			echo "		<transactionbalance>" . $row["bigint_TransactionBalance"] . "</transactionbalance>\n";			echo "		<transactiontimestamp>" . $row["timestamp_TransactionEvent"] . "</transactiontimestamp>\n";			echo "	</transaction>\n";		}	}}function gettransactions() {	$ret = "";	$sql = "SELECT * FROM 8_transactions WHERE bigint_SupplierID = ".$GLOBALS["s"]." AND timestamp_TransactionEvent >= \"".$GLOBALS["f"]."\" AND timestamp_TransactionEvent <= \"".$GLOBALS["t"]."\" ORDER BY bigint_TransactionID ASC;";	$result = mysql_query_errors($sql , $conn , __FILE__ , __LINE__ );	while ($row = mysql_fetch_array($result)) {		$leadid = $row["bigint_LeadID"];		$ret .= "	<tr>\n";		$ret .= "		<td><div class=\"timestamps\">" . (($leadid>0)?"#".($leadid+11001000)."<br />":"") . $row["timestamp_TransactionEvent"] . "</div></td>\n";		$ret .= "		<td><div class=\"transactions\">";		if ($leadid>0) {			$sql1 = "SELECT * FROM 6_serviceleads JOIN (5_suppliers,2_servicescatalogue,1_regions) ON (6_serviceleads.bigint_SupplierID = 5_suppliers.bigint_SupplierID AND 6_serviceleads.bigint_ServiceID = 2_servicescatalogue.bigint_ServiceID AND 6_serviceleads.bigint_RegionID = 1_regions.bigint_RegionID) WHERE bigint_LeadID = ".$leadid.";";			$result1 = mysql_query_errors($sql1 , $conn , __FILE__ , __LINE__ );			if ($row1 = mysql_fetch_array($result1)) {				$attr = split("<br />",$row1["text_LeadAttributes"]);				$attribsarr = array();				foreach ($attr as $value) {					// contact name populate & supplier name in subject					// make/model style					// requirement & budfget					// 3rde & 4de soos wat dit is					$val = split(" = ",$value);					$attribsarr[$val[0]] = $val[1];				}				$ret .= $attribsarr["products_description"].$attribsarr["vehicle_make_model"].((strlen($attribsarr["products_description"])==0)?" - ".$attribsarr["canopy_style"]:"")."<br />";				$ret .= $attribsarr["Requirement"].$attribsarr["canopy_req"]." - ".$attribsarr["Budget"].$attribsarr["budget"]."<br />";				$consumer = split(";",$row1["text_Consumer"]);				$ret .= $consumer[0]." (".$consumer[1].", ".$consumer[2].")<br />".				$row1["text_RegionDescription"]." (".$consumer[3].")";			}		} else {				$ret .= $row["text_TransactionEvent"];		}		$ret .= "</div></td>\n";		$ret .= "		<td><div class=\"amounts\">" . $row["bigint_TransactionAmount"] . "</div></td>\n";		$ret .= "		<td><div class=\"balances\">" . $row["bigint_TransactionBalance"] . "</div></td>\n";		$ret .= "	</tr>\n";	}	echo $ret;	return $ret;}function getsuppliers() {	$sql = "SELECT * FROM 5_suppliers WHERE smallint_SupplierStatus = 0 ORDER BY text_SupplierName ASC;";	$result = mysql_query_errors($sql , $conn , __FILE__ , __LINE__ );	if ($result) {		while ($row = mysql_fetch_array($result)) {			echo "	<supplier>\n";			echo "		<id>".$row["bigint_SupplierID"]."</id>\n";			echo "		<description>".$row["text_SupplierName"]."</description>\n";			if ($row["bigint_SupplierID"] == $GLOBALS["s"]) {				echo "		<selected>selected</selected>\n";			}			echo "	</supplier>\n";		}	}}function monthadd($date, $month) {	$now = getdate(strtotime(date("Y-m-d H:i:s", $date)));	return strtotime(date("Y-m-1 00:00:00",mktime(0,0,0,$now["mon"]+$month,1,$now["year"])));}function monthsub($date, $month) {	$now = getdate(strtotime(date("Y-m-d H:i:s", $date)));	return strtotime(date("Y-m-t 23:59:59",mktime(23,59,59,$now["mon"]-$month+1,0,$now["year"])));}function getfromdates() {	$f = $GLOBALS["fs"];	while ($f <= $GLOBALS["fl"]) {		echo "	<fromdate>\n";		echo "		<text>1st ".date("F Y, H:i:s",$f)."</text>\n";		echo "		<value>".date("Y-m-d H:i:s",$f)."</value>\n";		if (date("Y-m-d H:i:s",$f) == $GLOBALS["f"]) echo "		<selected>selected</selected>\n";		echo "	</fromdate>\n";		$f = monthadd($f,1);	}}function gettodates() {	$t = $GLOBALS["ts"];	while ($t >= $GLOBALS["tl"]) {		echo "	<todate>\n";		echo "		<text>".date("tS F Y, H:i:s",$t)."</text>\n";		echo "		<value>".date("Y-m-d H:i:s",$t)."</value>\n";		if (date("Y-m-d H:i:s",$t) == $GLOBALS["t"]) echo "		<selected>selected</selected>\n";		echo "	</todate>\n";		$t = monthsub($t,1);	}}$response = "";header("Content-type: text/xml; charset=utf-8");echo "<?xml version=\"1.0\"?>\n";echo "<root>\n";switch ($q) {	case 1: // supplier <-- mail statement		// select supplier contact name and email address		$sql = "SELECT 4_servicesuppliers.bigint_ServiceID, 5_suppliers.bigint_SupplierID, 5_suppliers.text_SupplierName, CONCAT(5_suppliers.text_ContactFirstName, \" \", 5_suppliers.text_ContactSurname) AS text_ContactFullName, 5_suppliers.`text_ContactE-mail`, 5_suppliers.text_AccMgr, 5_suppliers.`text_AccMgrE-mail` FROM 5_suppliers LEFT JOIN 4_servicesuppliers ON (5_suppliers.bigint_SupplierID = 4_servicesuppliers.bigint_SupplierID) WHERE 4_servicesuppliers.bigint_SupplierID = ".$GLOBALS["s"]." AND smallint_SupplierStatus = 0 GROUP BY 5_suppliers.bigint_SupplierID;";		$result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false);		if ($result) {			while ($row = mysql_fetch_array($result)) {				include("../includes/mailer/class.phpmailer.php");											// include PHPMailer class				$toname = $row["text_ContactFullName"];				$toaddr = $row["text_ContactE-mail"];				$recipient[0] = $toname;				$recipient[1] = $row["text_SupplierName"];				$recipient[11] = $row["text_AccMgr"];				$recipient[12] = $row["text_AccMgrE-mail"];				// build mail and attempt sending, saving response				$body				 = getFile("/home/dwtphovu/public_html/intellisource.co.za/prod_8347379386/templat/statement.html");	// load mail template				$mail				= new PHPMailer();														// create a new object				$transactions		= gettransactions($row["bigint_SupplierID"]);							// build transactions html				$body				= populateflags($body);				/*$body				= str_replace("%MESSAGE%",$message,$body);								// insert statement message				$body				= str_replace("%TRANSACTIONS%",$transactions,$body);					// insert transaction records				$body				= str_replace("%FROMDATE%",date("jS F Y, H:i:s",strtotime($f)),$body);	// insert from date				$body				= str_replace("%TODATE%",date("tS F Y, H:i:s",strtotime($t)),$body);	// insert to date				$body				= str_replace("%LOGOURL%",$logourl,$body);								// insert logo url				$body				 = str_replace("%COPYRIGHT%","CanopyXchange",$body);						// insert copyright owner				$body				 = str_replace("%YEAR%",date("Y"),$body);								// insert copyright year*/				require("/home/dwtphovu/public_html/intellisource.co.za/prod_8347379386/includes/mailer/dwtphovu_auth.php");			// include mailer auth				$mail->From			= "canopy@canopyxchange.za.net";										// set from email				$mail->FromName		= "CanopyXchange";														// set from name				$mail->Subject		= getSubText($body,"<title>","</title>");								// replacing to and from dates				$mail->AddBCC("pierre@canopyxchange.za.net", "Pierre \"Greywacke\" du Toit");				// add the developer to the BCC list				$mail->AddBCC($recipient[12], $recipient[11]);								// add the account manager to the BCC list				$mail->ClearAttachments();																	// clears attachments				$mail->MsgHTML($body);																		// set HTML Body				$mail->AltBody = strip_tags(html_entity_decode(getSubText($body,"<body>","</body>")));		// set Text Body				//$mail->AddAddress($toaddr, $toname);														// add recipient				$mail->IsHTML(true);																		// set send as HTML				if(!$mail->Send()) {																		// if attempt sending failed						$response = "FAILURE: ".$toname.", ".$toaddr." (".$mail->ErrorInfo.")";					// save error report				} else {																					// else					$response = "SUCCESS: ".$toname.", ".$toaddr;											// save success report				}																							// end if			}		}		break;	case 2: // acc manager <-- mail statement		// select supplier contact name and email address		$sql = "SELECT 4_servicesuppliers.bigint_ServiceID, 5_suppliers.bigint_SupplierID, 5_suppliers.text_SupplierName, CONCAT(5_suppliers.text_ContactFirstName, \" \", 5_suppliers.text_ContactSurname) AS text_ContactFullName, 5_suppliers.`text_ContactE-mail`, 5_suppliers.text_AccMgr, 5_suppliers.`text_AccMgrE-mail` FROM 5_suppliers LEFT JOIN 4_servicesuppliers ON (5_suppliers.bigint_SupplierID = 4_servicesuppliers.bigint_SupplierID) WHERE 4_servicesuppliers.bigint_SupplierID = ".$GLOBALS["s"]." AND smallint_SupplierStatus = 0 GROUP BY 5_suppliers.bigint_SupplierID;";		$result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false);		if ($result) {			while ($row = mysql_fetch_array($result)) {				include("../includes/mailer/class.phpmailer.php");											// include PHPMailer class				$toname = $row["text_AccMgr"];				$toaddr = $row["text_AccMgrE-mail"];				$recipient[0] = $toname;				$recipient[1] = $row["text_SupplierName"];				$recipient[11] = $toname;				$recipient[12] = $toaddr;				// build mail and attempt sending, saving response				$body				 = getFile("/home/dwtphovu/public_html/intellisource.co.za/prod_8347379386/templat/statement.html");	// load mail template				$mail				= new PHPMailer();														// create a new object				$transactions		= gettransactions($row["bigint_SupplierID"]);							// build transactions html				$body				= populateflags($body);				/*$body				= str_replace("%MESSAGE%",$message,$body);								// insert statement message				$body				= str_replace("%TRANSACTIONS%",$transactions,$body);					// insert transaction records				$body				= str_replace("%FROMDATE%",date("jS F Y, H:i:s",strtotime($f)),$body);	// insert from date				$body				= str_replace("%TODATE%",date("tS F Y, H:i:s",strtotime($t)),$body);	// insert to date				$body				= str_replace("%LOGOURL%",$logourl,$body);								// insert logo url				$body				 = str_replace("%COPYRIGHT%","CanopyXchange",$body);						// insert copyright owner				$body				 = str_replace("%YEAR%",date("Y"),$body);								// insert copyright year*/				require("/home/dwtphovu/public_html/intellisource.co.za/prod_8347379386/includes/mailer/dwtphovu_auth.php");			// include mailer auth				$mail->From			= "canopy@canopyxchange.za.net";										// set from email				$mail->FromName		= "CanopyXchange";														// set from name				$mail->Subject		= getSubText($body,"<title>","</title>");								// replacing to and from dates				$mail->AddBCC("pierre@canopyxchange.za.net", "Pierre \"Greywacke\" du Toit");				// add the developer to the BCC list				$mail->ClearAttachments();																	// clears attachments				$mail->MsgHTML($body);																		// set HTML Body				$mail->AltBody = strip_tags(html_entity_decode(getSubText($body,"<body>","</body>")));		// set Text Body				$mail->AddAddress($toname, $toaddr);														// add recipient				$mail->IsHTML(true);																		// set send as HTML				if(!$mail->Send()) {																		// if attempt sending failed						$response = "FAILURE: ".$toname.", ".$toaddr." (".$mail->ErrorInfo.")";					// save error report				} else {																					// else					$response = "SUCCESS: ".$toname.", ".$toaddr;											// save success report				}																							// end if			}		}		break;	default: // (re)load form}$arr = array();if ($s > 0) {	array_push($arr,"bigint_SupplierID = ".$s);}array_push($arr,"timestamp_TransactionEvent >= \"".$f."\"");array_push($arr,"timestamp_TransactionEvent <= \"".$t."\"");getrecords($arr);getsuppliers();getfromdates();gettodates();if ($response) echo "	<result>".$response."</result>\n";echo "	<sql>".xmlentities(join("\n",$sql))."</sql>\n";echo "</root>";mysql_close($conn);?>

this is supposed to show the result, but it does not even do that. :) something is causing it to end prematurely, how would i find out what that is if this page does not give any errors? it finds the supplier, by id 38 ($s = 38). it gets the transactions, and populates those values. it includes phpmailer, and the timezone conversion class.somebody please help! even with ideas on how to debug.

Link to comment
Share on other sites

When I'm debugging ajax I use an error log to help. Enable error logging in PHP and then you can use the error_log function to send whatever information you want to that file to help track what the script is doing.ini_set('log_errors', 1);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('display_errors', 0);error_reporting(E_ALL);

Link to comment
Share on other sites

ahhhh *wana kick self*the problem was the $service variable and the extra $q parameter not being allowed for. this works now ^^ :)

Link to comment
Share on other sites

Not a good thing or a bad thing, but your code always looks incredibly complicated...

Link to comment
Share on other sites

haha yeah i get you there - i believe everything is possible with code. in time we'll even be able to steer boeings from websites 0ojust with the health problems its a bit harder than usual atm :) but i will always love coding :)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...