dynamicOne
asked on
Send generic email message if condition is met via php
I can't find how to do this on the Web. I want to send an email via php after a condition is met.
Any ideas on how to do it?
Any ideas on how to do it?
ASKER
Kent,
Maybe I am just not seeing it. What I want to do is send an email when the state of my garage door changes. I am reading the state of the door using a magnetic switch. Here is the code I am using.
<?php
$switch = exec('/usr/local/bin/gpio read 1');
if ($switch == "1"){
echo "<img src='garage-door-open.jpeg ' width='497px' height='448px'/>";
}
if ($switch == "0"){
echo "<img src='garage-door-close.jpe g' width='497px' height='448px'/>";
}
?>
In addition to echoing the image, I would like to send an email. I have .php file created that when it is loaded in the browser it sends a message. Is there a way I could call that file without displaying it in the browser?
Maybe I am just not seeing it. What I want to do is send an email when the state of my garage door changes. I am reading the state of the door using a magnetic switch. Here is the code I am using.
<?php
$switch = exec('/usr/local/bin/gpio read 1');
if ($switch == "1"){
echo "<img src='garage-door-open.jpeg
}
if ($switch == "0"){
echo "<img src='garage-door-close.jpe
}
?>
In addition to echoing the image, I would like to send an email. I have .php file created that when it is loaded in the browser it sends a message. Is there a way I could call that file without displaying it in the browser?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help Kent, I was over thinking it. It was just a matter of creating a function and calling it in the condition.
http://us1.php.net/manual/en/function.mail.php
There are quite a few examples provided by the community.. Including using If.. checking, etc.
HTH,
Kent