@@ -17,9 +17,10 @@ foreach ($userarr['users'] as $userkey => $userval) { //遍历用户json生成
1717 $ location = ($ userval ['location ' ]);
1818 $ usermail = ($ userval ['usermail ' ]);
1919 $ userid = ($ userval ['userid ' ]);
20- $ usersunflag = ($ userval ['usersunflag ' ]);
20+ $ usersunflag = ($ userval ['usersunflag ' ]);//非雨天也发邮件(不设置天气过滤)将config中usersunflag设为true
2121 $ usertime = ($ userval ['usertime ' ]);
22- $ usertemp = ($ userval ['usertemp ' ]);
22+ $ usertempflag = ($ userval ['usertempflag ' ]);
23+ //$usertempflag = ($userval['usertempflag']);//高温预警设置,将config中usertempflag设为true,温度高于36度时推送邮件
2324 $ jsonadd = "https://free-api.heweather.com/s6/weather/forecast?location= {$ location }&key= {$ Hekey }" ; //json地址
2425 $ weatherjson = file_get_contents ($ jsonadd );
2526 $ weatherarr = json_decode ($ weatherjson , TRUE );
@@ -50,7 +51,7 @@ foreach ($userarr['users'] as $userkey => $userval) { //遍历用户json生成
5051 };
5152 if (strstr ($ weather0 , "雨 " )) {
5253 $ tips = "需要带伞 " ; //带伞通知
53- $ subject = "今天会下雨哦 " ; //邮件主题
54+ $ subject = "今天会下雨哦~ " ; //邮件主题
5455
5556 } else {
5657 $ tips = "不需要带伞 " ;
@@ -59,6 +60,14 @@ foreach ($userarr['users'] as $userkey => $userval) { //遍历用户json生成
5960 $ weather0 = $ weather0 . ", " . $ winds [0 ] . ", " . $ tmps [0 ]; //整合天气数据
6061 $ weather1 = $ weather1 . ", " . $ winds [1 ] . ", " . $ tmps [1 ];
6162 $ weather2 = $ weather2 . ", " . $ winds [2 ] . ", " . $ tmps [2 ];
63+ $ d0maxtemp = ($ weatherarr ['HeWeather6 ' ][0 ]['daily_forecast ' ][0 ]['tmp_max ' ]);
64+ //echo $d0maxtemp;
65+ if ($ d0maxtemp > 36 ){
66+ if ($ usertempflag == 'true ' ){
67+ $ subject = $ subject ."还贼热 " ;
68+ $ usersunflag = "true " ;
69+ }
70+ }
6271 //邮件部分
6372 $ mailstr = <<<LABELSS
6473<style type="text/css">
@@ -205,20 +214,22 @@ LABELSS;
205214 if (strstr ($ weather0 , "雨 " )) { //判断天气情况,发送邮件
206215 $ mailto = $ usermail ; //收件人
207216 $ body = $ mailstr ; //邮件内容
208- sendmailto ($ mailto , $ subject , $ body );
217+ print_r ($ mailstr );//web预览邮件样式
218+ //sendmailto($mailto, $subject, $body);
209219 } else {
210220 if ($ usersunflag == 'true ' ) {
211221 $ mailto = $ usermail ;
212222 $ body = $ mailstr ;
213- sendmailto ($ mailto , $ subject , $ body );
223+ print_r ($ mailstr );//web预览邮件样式
224+ //sendmailto($mailto, $subject, $body);
214225 }
215226 };
216227 $ data = "" ; //初始化天气数据
217228 $ txt_d = "" ;
218229 $ txt_n = "" ;
219230 $ winds = "" ;
220231 $ tmps = "" ;
221- print_r ( $ mailstr ); //web预览邮件样式
232+
222233 }
223234}
224235?>
0 commit comments