Location: PHPKode > projects > Total ISP > total-isp/sendmail.php

include "./auth.inc.php";
$sql="SELECT ContactEmail FROM MasterAccounts WHERE NOT ISNULL(ContactEmail) AND ContactEmail !=''";

if ($filter)
	$sql = "SELECT ContactEmail 
		FROM MasterAccounts,SubAccounts 
		WHERE NOT ISNULL(ContactEmail) 
		AND ContactEmail !='' 
		AND AccountType='$filter'
		AND MasterAccounts.CustomerID = SubAccounts.CustomerID";

if ($to)
	$sql=$sql." AND MasterAccounts.VISP=$to";

while ($row=mysql_fetch_row($res)){
	$bcc=$bcc."$row[0], ";
$bcc="Bcc: ".$bcc."\r\n";

if ($Approved){
	#send it

	$header=$header."Reply-To: $SUPPORT_EMAIL\n";
	$header=$header."Precedence: bulk\n";
	$header=$header."Errors-To: $SUPPORT_EMAIL\n";


	#print "<PRE>$header</PRE>";

	$x = mail ('$ISPNAME Users <all@$DEFAULT_EMAIL_DOMAIN>',$Subject,$Body,$header);
	if ($x)
		print "Message Sent. $x";
		print "An Error Occurred sending this mail. $x. $header";

$Body = stripslashes($Body);

print "Subject: <B>$Subject</B><BR>";
print "Message: <BR><TABLE BORDER=1><TR><TD>";
print ereg_replace("\n","<BR>",$Body);
print "</TD></TR></TABLE>";

print "<FORM>";
print "<INPUT TYPE=HIDDEN NAME=Subject VALUE=\"$Subject\">\n";
print "<INPUT TYPE=HIDDEN NAME=Body VALUE=\"$Body\">\n";
print "<INPUT TYPE=HIDDEN NAME=Approved VALUE=1>\n";
print "<INPUT TYPE=HIDDEN NAME=to VALUE=\"$to\">\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Send Now\">";
print "</FORM>";

print "$bcc";
Return current item: Total ISP