<?php
error_reporting(E_ALL ^ E_NOTICE);
mysql_connect("localhost","....");
mysql_select_db("...");
mysql_query("SET NAMES 'utf8'");
$count = 0;
$today = time();
$year = date("Y",$today);
$month = date("m",$today);
$day = date("j",$today);
$mail_day = date("j F Y",$today);
$result = mysql_query("SELECT l.listing_member, m.member_email, m.member_email2, l.listing_date_expired, l.listing_title, l.listing_id, l.listing_mls, l.listing_owner, l.listing_owner_phone FROM listing as l inner join member as m on m.member_id=l.listing_member order by l.listing_member asc");
$member_change='';
$mail['items_list']='';
while($row = mysql_fetch_assoc($result)){
$date = explode("-",$row['listing_date_expired']);
$listing_member = $row['listing_member'];
$member_email = $row['member_email'];
$member_email2 = $row['member_email2'];
if($member_email2!="")
{
$to=$member_email.",".$member_email2;
}
else
{
$to=$member_email;
}
$bcc="[email protected]";
if($member_change=="")
{
$member_change=$to;
}
if($member_change!=$to)
{
$to=$member_change;
$member_change='';
/* Mail to Users */
if($to!="")
{
$mail['header'] = 'MIME-Version: 1.0' . "\r\n";
$mail['header'] .= 'Bcc: ' . $bcc . "\r\n";
$mail['header'] .= 'Content-type: text/html; charset=utf-8' . "\r\n";
}
else
{
$to=$bcc;
$mail['header'] = 'MIME-Version: 1.0' . "\r\n";
$mail['header'] .= 'Content-type: text/html; charset=utf-8' . "\r\n";
}
$mail['message'] = "
<h1>Expired Property Today</h1>
<h3>Date: ". $mail_day ."</h3>
<hr/>
". $mail['items_list'] ."
";
mail($to,"Expired Property Today",$mail['message'],$mail['header']);
$mail['items_list']="";
}
if(($date[0] == $year) && ($date[1] == $month) && ($date[2] == $day)){
$mail['items_list'] .= "
<strong>". $row['listing_title'] ."</strong><br/>
ID: ". $row['listing_id'] ."<br/>
MLS: ". $row['listing_mls'] ."<br/>
Owner: ". $row['listing_owner'] ."<br/>
Phone: ". $row['listing_owner_phone'] ."<br/>
<hr/>
";
$count++;
}
}
if($count == 0){
$content = "No expired property today.";
} else {
$content = "$cont Expired today.";
}
header ('Content-type: text/html; charset=utf-8');
echo $content;
?>
|