Thank you for your reply!
I'll try to be more descriptive. I'm using a Ubuntu Server with LAMP and installed the follow to send mail using php:
apt-get install php-pear
pear install mail
pear install Net_SMTP
pear install Auth_SASL
pear install mail_mime
apt-get install postfix
This is the script I'm using now to report the host address (no real reason for me to do it!). The following script works without a problem:
<?php
$to = "me@example.com";
$subject = "Router ip address";
$body = exec('ifconfig eth0 | grep "inet addr"');
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
Thanks for your curl command! I have it working now. The code for reporting my public ip address is as follows:
<?php
$to = "me@example.com";
$subject = "Routers ip address";
$body = exec("curl -s
http://whatsmyip.net/ |grep -i '<title>' | cut -d : -f$
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
I would like this script to only send a message when the ip address changes if possible. I don't know much about cron jobs yet and have never set it up before.
Would there be another way to do get the public ip address? Maybe using SNMP? Just an idea.
We don't have the router were we're deploying yet, and I'm not allowed to configure it.