<?phpif(_SERVER("REQUEST_METHOD"))exit;// avoid php execution via http requestinclude_once"/lib/sn_dns.php";include_once"/lib/sn_esmtp.php";include_once"/lib/sd_340.php";functionsend_email(){esmtp_account("[email protected]","Water Sensor");esmtp_auth("[email protected]","your_password");esmtp_msa("smtp.gmail.com",465);$subject="Water Leak";$message="Water leak is deteated\r\n";$msg=esmtp_send("[email protected]","to_name",$subject,$message);if($msg=="221")echo"send mail successful\r\n";elseecho"send mail failed\r\n";}uio_setup(0,0,"in");$previous_value=1;while(1){$current_value=uio_in(0,0);if($current_value==0&&$previous_value==1)send_email();$previous_value=$current_value;sleep(1);}?>
Comments