Question : Modify Cron Job

I need to modify the code for this cron job to do the following:

1. Only send email to the first email address - no need to send email 2
2. Do not send the email if there is are NO EXPIRED PROPERTIES
3. Send the email one day BEFORE the property expires - not the day of .. .
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
<?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;
?>

Answer : Modify Cron Job

As I said "may be" you need to change on your discretion the following texts
"Expired Property Today" to "Property Expiring Tomorrow",
"No expired property today." to "No property expiring tomorrow"
"$count Expired today." to "$count Expiring tomorrow."

Since it is not much of a functional thing, and am not sure of your requirement, I kept away from changing texts.
Random Solutions  
 
programming4us programming4us