I have the following working on a shared server, but for the life of me can't get it to work on my Linux server thats in my place. The code is supposed to email me the current ip of the server (since it has a dynamic IP) and email it to myself. When I test the file it echos "nope, it didn't work." I am trying to get the linux server to call this file on startup - so i put it in rc.local. I hope this captures the ip and sends it to me via email. Thanks for taking a look.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Send Mail</title>
</head>
<body>
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$charset = 'UTF-8';
// the email where it gets delivered to
$to = "my@err.com";
// the originator of the email
$senderMail = "info@ux.com";
$senderName = "from me";
$senderSubject = "Home Server IP";
$senderBody = "http://$ip";
//Add header information
$headers = "From: $senderName <$senderMail>\r\n";
$headers .= "Reply-To: $senderName <$senderMail>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/plain; charset=$charset; format=flowed\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "X-Mailer: PHP\n";
if(@mail($to, $senderSubject, $senderBody, $headers)){
echo "it worked";
}
else
{
echo "nope, it didn't work.";
}
?>
</body>
</html>