\r\n"; will always be builder@bstapps.com // $headers.="To: ".$ToName." <".$To.">\r\n"; // $headers.="CC: ".$CcName." <".$CC.">\r\n"; /***************************************************************************************/ include "Blacklist.inc"; function getCCEmails ($fileName, $centre = null, $phase = null) { global $db; if (! $centre) $centre = "All"; if (! $phase) $phase = "All"; $sql = " SELECT tb_Users.col_UsersName, tb_Users.col_EmailAddress FROM tb_UsersSendCC RIGHT JOIN tb_Users ON tb_UsersSendCC.col_UsersID = tb_Users.col_UsersID WHERE col_Centre = '$centre' AND col_Phase = '$phase' AND col_ActiveYN = 'Yes' AND col_FileName = '$fileName' "; $users = $db->query($sql)->fetchAll(); foreach ($users as $user) { $var_CC .= $user['col_UsersName'] . " <" . $user['col_EmailAddress'] . ">, "; } return $var_CC; } function SendMailBST($From,$FromName,$To,$ToName,$Cc,$CcName,$Subject,$Text,$Html,$AttmFiles, $CCs = null) { $var_Status = CheckEmailBlacklist($From, $To, $Subject, $Text, $Html); return SendMailAll(0,$From,$FromName,$To,$ToName,$Cc,$CcName,$Subject,$Text,$Html,$AttmFiles, $CCs)? $var_Status : 'failed'; } function SendMailFax($From,$FromName,$To,$ToName,$Cc,$CcName,$Subject,$Text,$Html,$AttmFiles, $CCs = null) { return SendMailAll(1,$From,$FromName,$To,$ToName,$Cc,$CcName,$Subject,$Text,$Html,$AttmFiles, $CCs)? 'success' : 'failed'; } function SendMailAll($Fax,$From,$FromName,$To,$ToName,$Cc,$CcName,$Subject,$Text,$Html,$AttmFiles, $CCs) { $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"; //////////////////////////////////////////////////////////////////////////////////// // We are now going to always send mail from builder@bstapps.com // 10oct16 if ($ToName) $ToX = $ToName." <".$To.">\r\n"; else $ToX = $To."\r\n"; if ($Fax) { $FromBuilder = $From; $FromBuilderName = $FromName; } else { $FromBuilder = "builder@bstapps.com"; $FromBuilderName = "Care of "; $FNX = substr($From,0,strpos($From,"@")); $FromBuilderName .= $FromName ? $FromName : $FNX; } //////////////////////////////////////////////////////////////////////////////////// // address section if ($FromBuilderName) $headers.="From: ".$FromBuilderName." <".$FromBuilder.">\r\n"; else $headers.="From: ".$FromBuilder."\r\n"; //php mail already adds to we do not need to add it twice //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"; elseif ($CCs) $headers .= "Cc: " . $CCs . "\r\n"; if ($Bcc) $headers.="Bcc: ".$Bcc."\r\n"; $headers.="Reply-To: ".$FromName." <".$From.">\n"; // vince remed $var_Param = "-f".$From; // header settings $headers.="X-Priority: 1\r\n"; $headers.="X-MSMail-Priority: High\r\n"; $headers.="X-Mailer: My PHP Mailer5.7\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 if ($Html) { $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($ToX,$Subject,$Msg,$headers,$var_Param); return $var_Pass_Fail; } /***************************************** BEGIN MAIN CODEBLOCK *****************************************************/ // OLDER VERSIONS OF SEND EMAIL FOR COMPATABILITY PURPOSES /***************************************************************************************/ // this is deprecated, should be replaced, but we 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 Mailer5.8\n"; $headers.="Content-Type: multipart/mixed;\n\tboundary=\"".$IB."\"\n"; // Vince Remed $var_Param = "-f".$From; $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,$var_Param); return $var_Pass_Fail; } /***************************************************************************************/ // this is deprecated, should be replaced, but we need to test first, as everyone uses it. 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"; // Vince Remed $var_Param = "-f".$From; //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

"; ?> --PHP-alt-
To: $to"; $mail_sent = mail( $to, $subject, $message, $headers , $var_Param); // return success or failure to the calling code, lets us diagnose success/failure. if($mail_sent) return 1; else return 0; } /***************************************************************************************/ // this is deprecated, should be replaced, but we need to test first, as everyone uses it. function SendMailPDF($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"); $headers ="MIME-Version: 1.0\r\n"; $headers.="From: ".$FromName." <".$From.">\n"; $headers.=($ToName)? "To: ". $ToName ." <".$To.">\n":""; $headers.="Cc: ".$FromName." <".$From.">\n"; $headers.='Bcc: system@buildersit.com' . "\r\n"; $headers.="Reply-To: ".$FromName." <".$From.">\n"; // Vince Remed $var_Param = "-f".$From; $headers.="X-Priority: 1\n"; $headers.="X-MSMail-Priority: High\n"; $headers.="X-Mailer: My PHP Mailer5.9\n"; $headers.="Content-Type: multipart/mixed;\n\tboundary=\"".$OB."\"\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"; // end of IB $Msg.="\n--".$IB."--\n"; // 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--".$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,$var_Param); return $var_Pass_Fail; } /***************************************** END MAIN CODEBLOCK *****************************************************/ ?>