System information
An Introduction to PHP3
Axis Communications AB provides NO support for application development of any kind. The information
here is provided "as is", and there is no guarantee that any of the examples shown will work in your
particular application.
Revision 1.02 October 2002 32
4.2.3 Example 3 – FTP and E-mail on Event
This script will upload 2 pre-alarm and 2 post-alarm images via FTP and also send an e-mail as
notification of the event. In addition to the parameters in example 1, the following parameters are
added:
<?
$smtp_server = "mail.somewhere.com";// The server to use as mail server
$subject = "'Alarm trigged'"; // The subject to use in the mail
$from = "someone@somewhere.com"; // The specified sender
$reply = " someone1@somewhere.com ";// The specified recipient
$cc = " someone2@somewhere.com "; // The specified recipient of a
//copy of this mail
$body = "/tmp/var/log/messages"; // The body to insert into the
// mail. Note that this must be
//specified and point to a valid
//file
$to = " someone@somewhere.com "; // The specified recipient
The script itself is identical to example 1, except for the extra lines shown below.
for($c=0;$c<(strlen($sources));$c++)
{
$command="bufferd -stop -buffername
".$buffer_prefix.substr($sources,$c,1);
system($command);
}
//This is where the code specific to Example 2 starts.
$command = "smtpclient";
$command .=" -L -S ".$smtp_server;
$command .=" -s ".$subject;
$command .=" -f ".$from;
$command .=" -r ".$reply;
$command .=" -c ".$cc;
$command .=" -b ".$body;
$command .=" ".$to;
exec($command);
//This is where the code specific to Example 2 ends.
error_reporting(0);
………………the rest of the script as for example 1.