Link to home
Start Free TrialLog in
Avatar of dynamicOne
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?
Avatar of Kent Dyer
Kent Dyer
Flag of United States of America image

Does this not satisfy you needs?

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
Avatar of dynamicOne
dynamicOne

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.jpeg' 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?
ASKER CERTIFIED SOLUTION
Avatar of Kent Dyer
Kent Dyer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.