Jump to content

Content-type appearing in email body


glancey

Recommended Posts

Hey guys,

 

I know nothing of PHP so please bare with me as I try to explain my problem.

 

My company collects sales leads that are emailed through to a CRM system (GoldMine). We are currently in the process of moving our website from a shared windows server to a dedicated linux server and it seems to be causing a problem with the form, or at least PHP behind it. The guy who handed the initial set up has mysteriously disapeared so we're in a bit of a fix.

 

I'm not specifically looking for a solution, more of an idea of where to go from here. I'm not sure wether the problem lies in the PHP itself or something else.. like the server for example. I was hoping someone here might be able to point me in the right direction somewhat.

 

Anyway, the problem is that while testing the form on the new server the email is sent and our CRM picks it up but cannot read because a newly appeared line has been inserted at the top of the body. This does not appear when filling in the form currently live on our site (windows server).

 

the line is:

 

Content-Type: text/x-gm-impdata

 

As far as I'm aware this content-type is necessary for our CMR to recognize and read the email, but it shouldn't be showing up in the body of the mail.

 

The full on send PHP is:

 

<?php

$redirectURL = "http://www.website.co.uk/confirmation_page.htm";

function Decode($strValueIn)
{
//Do not modify this function!
$intX = 0;
$intY = 0;
$Temp = "";
$Mod = "";
$intMod =0;
$intTemp = 0;
$ValueOut = "";
$intY = 1;
$strValueOut="";
for ($intX=1; $intX<=((strlen($strValueIn)/2)/2); $intX=$intX+1)
  {

    $strTemp="";
    $strMod="";
    if (($intX % 2)==0)
    {

      $strMod=substr(substr($strValueIn,$intY-1,4),0,2);
      $strTemp=substr(substr($strValueIn,$intY-1,4),strlen(substr($strValueIn,$intY-1,4))-(2));
    }
      else
    {

      $strMod=substr(substr($strValueIn,$intY-1,4),strlen(substr($strValueIn,$intY-1,4))-(2));
      $strTemp=substr(substr($strValueIn,$intY-1,4),0,2);
    } 

    $intMod=hexdec($strMod);
    $intTemp=hexdec($strTemp);
    $intTemp=$intTemp-$intMod;
    $strValueOut=$strValueOut.chr($intTemp);
    $intY=$intY+4;

  } 

  return $strValueOut;



}

if ($_POST["GMsubmit"]!="")
{
$Body = "";

$Notes = "";

$SendToEmail = Decode($_POST["SendToEmail"]);
//$SMTP = Decode($_POST["SMTP"]); //Your SMTP data may have to be set set on the Apache Server, and this variable is not used.
$OnNewSendGMEmail = $_POST["OnNewSendGMEmail"];
if ($OnNewSendGMEmail!="")
	{$OnNewSendGMEmail = Decode($OnNewSendGMEmail);}
else 
	{$OnNewSendGMEmail = "";}

if ($_POST["OnDUPSendGMEmail"]!="")
	{$OnDUPSendGMEmail = Decode($_POST["OnDUPSendGMEmail"]);}
else 
	{$OnDUPSendGMEmail = "";}
if ($_POST["OnNewAttachTrack"]!="")
	{$OnNewAttachTrack = Decode($_POST["OnNewAttachTrack"]);}
else 
	{$OnNewAttachTrack = "";}
if ($_POST["OnDupAttachTrack"]!="")
	{$OnDupAttachTrack = Decode($_POST["OnDupAttachTrack"]);}
else 
	{$OnDupAttachTrack = "";}
if ($_POST["Word"]!="")
	{$Password = Decode($_POST["Word"]);}
else 
	{$Password = "";}
if ($_POST["DupLogic"]!="")
	{$DupLogic = Decode($_POST["DupLogic"]);}
else 
	{$DupLogic = "";}

$OutputAs = $_POST["OutPutAs"];
$DuplicateCount=0;
$XML = "<gmdata>";

if ($_POST["DuplicateCount"]!="") 
{
	$DuplicateCount =intval($_POST["DuplicateCount"]);

}
if ($DuplicateCount >0 || $OnNewSendGMEmail!="" || $OnDUPSendGMEmail!="" ||
	$OnNewAttachTrack!="" || $OnDupAttachTrack!="")
{
	$Body = $Body."[instructions]\r\n";
	$XML = $XML."<Instructions>";
	if ($DuplicateCount > 0)
	{
		for($counter=0; $counter < $DuplicateCount; $counter++)
		{
			$RealCount=$counter+1;
			$str = "DuplicateChecking$RealCount";
			eval("\$str = \"$str\";");
			$Body = $Body."DupCheck".$RealCount."=".$_POST[$str]."\r\n";
			//print($str.":".$_POST[$str].";");
			$tempVal = $_POST[$str];
			if ($tempVal==="EMAIL")
			{
				$XML = $XML."<DupCheck>EA1</DupCheck>";
			}
			else
			{
				if ($tempVal==="WEBSITE")
				{
					$XML = $XML."<DupCheck>WS1</DupCheck>";
				}
				else
				{
					$XML = $XML."<DupCheck>".htmlspecialchars($_POST[$str])."</DupCheck>";
				}
			}
		}
		if ($DupLogic !="")
		{$Body = $Body."DupLogic=OR\r\n";}
	}
	if ($OnNewSendGMEmail!="")
	{
		$Body = $Body."OnNewSendGMEmail=".$OnNewSendGMEmail."\r\n";
		$XML = $XML."<OnNewSendGMEmail>".htmlspecialchars($OnNewSendGMEmail)."</OnNewSendGMEmail>";

	}
	if ($OnDUPSendGMEmail!="")
	{
		$Body = $Body."OnDUPSendGMEmail=".$OnDUPSendGMEmail."\r\n";
		$XML = $XML."<OnDupSendGMEmail>".htmlspecialchars($OnDUPSendGMEmail)."</OnDupSendGMEmail>";

	}
	if ($OnNewAttachTrack!="")
	{
		$comma =strpos($OnNewAttachTrack, ",");
		$Body = $Body."OnNewAttachTrack=".$OnNewAttachTrack."\r\n";
		if ($comma =="")
		{
			$XML = $XML."<OnNewAttachTrack>".htmlspecialchars($OnNewAttachTrack)."</OnNewAttachTrack>";
		}
		else
		{
			list($track, $user) = split(',', $OnNewAttachTrack,2);
			$XML = $XML."<OnNewAttachTrack User=".chr(34).htmlspecialchars($user).chr(34).">".htmlspecialchars($track)."</OnNewAttachTrack>";
		}
	}
	if ($OnDupAttachTrack!="")
	{
		$comma =strpos($OnDupAttachTrack, ",");
		$Body = $Body."OnDupAttachTrack=".$OnDupAttachTrack."\r\n";
		if ($comma =="")
		{
			$XML = $XML."<OnDupAttachTrack>".htmlspecialchars($OnDupAttachTrack)."</OnDupAttachTrack>";
		}
		else
		{
			list($track, $user) = split(',', $OnDupAttachTrack,2);
			$XML = $XML."<OnDupAttachTrack User=".chr(34).htmlspecialchars($user).chr(34).">".htmlspecialchars($track)."</OnDupAttachTrack>";
		}


	}
	if ($Password!="")
	{
		$Body = $Body."Password=".$Password."\r\n";
		$XML = $XML."<Password>".htmlspecialchars($Password)."</Password>";

	}
	if ($DupLogic!="")
	{
		$XML = $XML."<DupLogic>OR</DupLogic>";
	}
	else
	{
		$XML = $XML."<DupLogic>AND</DupLogic>";
	}

	$XML = $XML."</Instructions>";
}
$Body = $Body."[Data]\r\n";
$XML = $XML."<accounts><account>";
$Phone = "";
$EA = "";
$WS = "";
$PR = "";
while(list($key,$value)= each($_POST)) 
{
	eval("$\$key = \"$value\";");
	{


		if ($key!="GMsubmit" && $key!="SMTP" && $key!="OnNewSendGMEmail" &&
			$key!="OnDUPSendGMEmail" && $key!="OnNewAttachTrack" &&
			$key!="OnDupAttachTrack" && $key!="SendToEmail" && $key!="DuplicateCount" && $key!="Word" &&
			strpos($key, "DuplicateChecking") === false && $key!="OutPutAs" && $key!="DupLogic" && strpos($key, "pretty_") === false)

		{


			if($value!="")
			{

				if ($key=="UHCUSTDESC" || $key=="UHDESCGOOD" || $key=="UHPI")
				{
					$value = str_replace("\r\n","<br/>",$value);
					$NoteHeader = "";
					if ($key=="UHCUSTDESC") { $NoteHeader = "<strong>Customer Description</strong><br/><br/>"; }
					if ($key=="UHDESCGOOD") { $NoteHeader = "<strong>Descriptions of Goods</strong><br/><br/>"; }
					if ($key=="UHPI")       { $NoteHeader = "<strong>Packing Information</strong><br/><br/>"; }
					$Notes = $Notes.$NoteHeader.$value."<br/><br/>";
				}


				$Body = $Body.$key."=".$value."\r\n";

				if (substr($key,0,5)!="PHONE" && substr($key,0,3)!="FAX" && substr($key, 0, 5)!="EMAIL" && substr($key,0, 7)!="WEBSITE")
      
				{

					$PR = $PR."<property name=".chr(34).$key.chr(34)." db_name=".chr(34).$key.chr(34).">";
					$PR = $PR."<property_string>".htmlspecialchars($value)."</property_string>";
					$PR = $PR."</property>";
				}
				else
				{
					if(substr($key,0,5)=="PHONE")
					{

					$Phone = $Phone."<phone international=".chr(34)."0".chr(34)." type=".chr(34).$key.chr(34)." source_fld=".chr(34).$key.chr(34).">";
					$Phone = $Phone."<properties><property name=".chr(34)."phone_number".chr(34)."><property_string>".$value."</property_string></property></properties>";
					$Phone = $Phone."</phone>";
					}
					elseif(substr($key,0,3)=="FAX")
					{
					$Phone = $Phone."<phone international=".chr(34)."0".chr(34)." type=".chr(34).$key.chr(34)." source_fld=".chr(34).$key.chr(34).">";
					$Phone = $Phone."<properties><property name=".chr(34)."phone_number".chr(34)."><property_string>".$value."</property_string></property></properties>";
					$Phone = $Phone."</phone>";
					}
					elseif(substr($key,0,7)=="WEBSITE")
					{
					$WS = $WS."<website primary=".chr(34)."1".chr(34)." id=".chr(34)."WS1".chr(34).">";
					$WS = $WS."<properties><property name=".chr(34)."web_site".chr(34)."><property_string>".$value."</property_string></property></properties>";
					$WS = $WS."</website>";
					}
					elseif(substr($key,0,5)=="EMAIL")
					{
					$EA = $EA."<email primary=".chr(34)."1".chr(34)." id=".chr(34)."EA1".chr(34).">";
					$EA = $EA."<properties><property name=".chr(34)."email_address".chr(34)."><property_string>".$value."</property_string></property></properties>";
					$EA = $EA."</email>";
					}

				}
			}	

		}
	}

}
if ($PR !="")
{$XML = $XML."<properties>".$PR."</properties>";}
if($Phone!="")
{
$XML = $XML."<phone_numbers>".$Phone."</phone_numbers>";
}
if($EA!="")
{
$XML = $XML."<emails>".$EA."</emails>";
}
if($WS!="")
{
$XML = $XML."<websites>".$WS."</websites>";
}
$XML = $XML."</account></accounts></gmdata>";
$ToSubject="Web Import";

//The PHP built in function mail() will not raise or cause errors if it fails - so be sure that your PHP server is setup correctly!

if( $OutputAs!="INI")
{
	$Body = $XML;
}
//ini_set("SMTP", Decode($SMTP));

$Body = $Body."UHSUBDATE=".date("d/m/Y")."\r\n";
$Body = $Body."NOTES=".$Notes;


if(mail(Decode($SendToEmail), $ToSubject, $Body, "From: GoldMine WebImport <no-reply@frontrange.com>\r\n\r\nContent-Type: text/x-gm-impdata\r\n\r\n" )) 
{
	//print "Your data has been recorded successfully!\r\n\r\n<!--\r\n".Decode($SendToEmail)."\r\n".$ToSubject."\r\n".$Body."\r\n\r\n".$OutputAs."\r\n\r\n-->";	
	header("location: ".$redirectURL);
}
else
{
	print("There was a mailer failure.\r\n\r\n<!--\r\n".$Body."\r\n\r\n-->");}
}
else
{
echo "There was no form data passed.";
}
?>

 

Line 294 contains the text that's appearing in the email.

 

Any ideas would be very, very much appreciated.

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.