\r\n";
// $headers.="To: ".$ToName." <".$To.">\r\n";
// $headers.="CC: ".$CcName." <".$CC.">\r\n";
/***************************************************************************************/
function SendMailBST($From,$FromName,$To,$ToName,$Cc,$CcName,$Subject,$Text,$Html,$AttmFiles)
{
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundery_001";
$Html=$Html?$Html:preg_replace("/\n/","{br}",$Text)
or die("neither text nor html part present.");
$Text=$Text?$Text:"Sorry, but you need an html mailer to read this mail.";
$From or die("sender address missing");
$To or die("recipient address missing");
// BCC for all emails sent
$Bcc = "system@buildersit.com";
$headers ="MIME-Version: 1.0\r\n";
// address section
if ($FromName)
$headers.="From: ".$FromName." <".$From.">\r\n";
else
$headers.="From: ".$From."\r\n";
if ($ToName)
$headers.="To: ".$ToName." <".$To.">\r\n";
else
$headers.="To: ".$To."\r\n";
if ($CcName)
$headers.="CC: ".$CcName." <".$Cc.">\r\n";
elseif ($Cc)
$headers.="CC: ".$Cc."\r\n";
if ($Bcc)
$headers.="BCC: ".$Bcc. "\r\n";
// header settings
$headers.="X-Priority: 1\r\n";
$headers.="X-MSMail-Priority: High\r\n";
$headers.="X-Mailer: My PHP Mailer\r\n";
$headers.="Content-Type: multipart/mixed;\n\tboundary=\"".$OB."\"\r\n";
//Messages start with text/html alternatives in OB
$Msg ="This is a multi-part message in MIME format.\n";
$Msg.="\n--".$OB."\n";
$Msg.="Content-Type: multipart/alternative;\n\tboundary=\"".$IB."\"\n\n";
//plaintext section
$Msg.="\n--".$IB."\n";
$Msg.="Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";
$Msg.="Content-Transfer-Encoding: quoted-printable\n\n";
// plaintext goes here
$Msg.=$Text."\n\n";
// html section
$Msg.="\n--".$IB."\n";
$Msg.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
$Msg.="Content-Transfer-Encoding: base64\n\n";
// html goes here
$Msg.=chunk_split(base64_encode($Html))."\n\n";
// end of IB
$Msg.="\n--".$IB."--\n";
// attachments
if($AttmFiles)
{
foreach($AttmFiles as $AttmFile)
{
$patharray = explode ("/", $AttmFile);
$FileName=$patharray[count($patharray)-1];
$Msg.= "\n--".$OB."\n";
$Msg.="Content-Type: application/octetstream;\n\tname=\"".$FileName."\"\n";
$Msg.="Content-Transfer-Encoding: base64\n";
$Msg.="Content-Disposition: attachment;\n\tfilename=\"".$FileName."\"\n\n";
//file goes here
$fd=fopen ($AttmFile, "r");
$FileContent=fread($fd,filesize($AttmFile));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$Msg.=$FileContent;
$Msg.="\n\n";
}
}
//message ends
$Msg.="\n--".$OB."--\n";
$var_Pass_Fail = mail($To,$Subject,$Msg,$headers);
return $var_Pass_Fail;
}
/***************************************** BEGIN MAIN CODEBLOCK *****************************************************/
// OLDER VERSIONS OF SEND EMAIL FOR COMPATABILITY PURPOSES
/***************************************************************************************/
// this is deprecated, should be replaced with SendMailVince, but need to test first, as everyone uses it.
function SendMail($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles)
{
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundary_001";
$Html=$Html?$Html:preg_replace("/\n/","
",$Text) or die("neither text nor html part present.");
$Text=$Text?$Text:"Sorry, but you need an html mailer to read this mail.";
$From or die("sender address missing");
$To or die("recipient address missing");
// echo "
in sendmail, to is $To
";
$headers ="MIME-Version: 1.0\r\n";
$headers.="From: ".$FromName." <".$From.">\n";
// $headers.=($ToName)? "To: ". $ToName ." <".$To.">\n":"";
$headers.="To: ". $ToName ." <".$To.">\n";
$headers.="Cc: ".$FromName." <".$From.">\n";
$headers.="BCC: System \n";
$headers.="Reply-To: ".$FromName." <".$From.">\n";
$headers.="X-Priority: 1\n";
$headers.="X-MSMail-Priority: High\n";
$headers.="X-Mailer: My PHP Mailer\n";
$headers.="Content-Type: multipart/mixed;\n\tboundary=\"".$IB."\"\n";
$Msg ="This is a multi-part message in MIME format.\n";
//$Msg.="\n--".$OB."\n";
//$Msg.="Content-Type: multipart/alternative;\n\tboundary=\"".$IB."\"\n\n";
//plaintext section
$Msg.="\n--".$IB."\n";
$Msg.="Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";
$Msg.="Content-Transfer-Encoding: quoted-printable\n\n";
// plaintext goes here
$Msg.=$Text."\n\n";
if($Html)
{
// html section
$Msg.="\n--".$IB."\n";
$Msg.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
$Msg.="Content-Transfer-Encoding: base64\n\n";
// html goes here
$Msg.=chunk_split(base64_encode($Html))."\n\n";
}
// end of IB
// $Msg.="\n--".$IB."--\n";
// echo $Msg;
// attachments
// echo "
attmfiles is $AttmFiles
";
if($AttmFiles)
{
foreach($AttmFiles as $AttmFile)
{
// echo "
attmfile is $AttmFile
";
$patharray = explode ("/", $AttmFile);
$FileName=$patharray[count($patharray)-1];
// echo "
filename is $FileName
";
$Msg.= "\n--".$IB."\n";
$Msg.="Content-Type: application/octetstream;\n\tname=\"".$FileName."\"\n";
$Msg.="Content-Transfer-Encoding: base64\n";
$Msg.="Content-Disposition: attachment;\n\tfilename=\"".$FileName."\"\n\n";
//file goes here
$fd=fopen ($AttmFile, "r");
$FileContent=fread($fd,filesize($AttmFile));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$Msg.=$FileContent;
$Msg.="\n\n";
}
}
//message ends
$Msg.="\n--".$IB."--\n";
$var_Pass_Fail = mail($To,$Subject,$Msg,$headers);
return $var_Pass_Fail;
}
/***************************************************************************************/
function SendMailVince($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles)
{
// echo $AttmFiles[0];
$var_AttmTemp = $AttmFiles[0];
// echo "Got called with From: $From fromname: $FromName To: $To ToName: $ToName Subject: $Subject Text: $Text HTML: $Html Attach: $var_AttmTemp
";
// for multiple recipients
$arr_toMultiple = array();
$arr_toMultiple = explode(" ", $To);
foreach($arr_toMultiple as $sendto)
{
$to .= $sendto.', ';
}
$tolen = strlen($to);
$to = substr($to, 0, ($tolen-2));
//define the receiver of the email
//define the subject of the email
$subject = $Subject;
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: $From\r\nReply-To: $From\r\n";
$headers.="CC: $From\r\nReply-To: $From\r\n";
$headers.="BCC: system@buildersit.com\r\n";
//add boundary string and mime type specification
$headers .= " \r\nMIME-Version: 1.0";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
// $attachment = chunk_split(base64_encode(file_get_contents('temp.pdf')));
$patharraytemp = explode ("/", $AttmFiles[0]);
$FileName_temp=$patharraytemp[count($patharraytemp)-1];
// echo "file name is $FileName_temp
";
//define the body of the message.
ob_start(); //Turn on output buffering
?>This is a multi-part message in MIME format.
--PHP-mixed-
Content-Type: multipart/alternative;
boundary="PHP-alt-"
--PHP-alt-
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
--PHP-alt-
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
$Html