I'm trying to create a script that lets me plug in a router anywhere in the world and have it send me an email every certain amount of time.
Here is the script I have so far.
Quote:
#!/bin/sh
# WANIPCheck
# Some settings
INTERVAL=10
## SMTP="smtp.secureserver.net"
## FROM="test@myisp.com"
## FROM_NAME="JohnQ"
## USER="mylogin@mydomain.com"
## PASSWORD="XXXX"
## SUBJECT="TEST 1"
## MESSAGE="Test number 1"
## TO="test@anyemailaddress.com"
MAIL_BINARY=/jffs/sendmail
MAIL_SERVER="mail.myisp.ca"
## USER="user@myisp.ca"
## PASSWORD="xxxxx"
MAIL_TO="mail@anyemailaddress.com"
MAIL_FROM="mail@mydomain.com"
MAIL_SUBJECT="Router IP Address Update"
# Function for sending the log to an email address
##sendemail()
# The "main" loop
while sleep $INTERVAL
do
{
# Create the email message
CURR_WAN_IPADDR=`nvram get wan_ipaddr`
echo "Subject: $MAIL_SUBJECT" > /tmp/mailnotification
echo "WAN IP-Address is:"$CURR_WAN_IPADDR >> /tmp/mailnotification
# Send the email message
## /jffs/sendmail -S"$SMTP" -f$FROM -F"$FROM_NAME" -d"$DOMAIN" -u"$USER" -p"$PASSWORD" -s"$SUBJECT" -m"$MESSAGE" $TO
cat /tmp/mailnotification | $MAIL_BINARY -s$MAIL_SERVER -f$MAIL_FROM -v $MAIL_TO
# Cleanup email message
## echo $MAIL_BINARY
## echo $MAIL_SERVER
## echo $MAIL_TO
## echo $MAIL_FROM
## echo $MAIL_SUBJECT
cat /tmp/mailnotification
## rm /tmp/mailnotification
}
done
|
Ignore all the lines I commented out. I'm just playing around and don't want to delete stuff I might need.
I have gotten this working through my ISPs SMTP servers, but as soon as I try to use Gmail, Hotmail, or my domain's SMTP server(GoDaddy)....it doesn't go through.
I need to be able to modify the script to login and authorize the username/password, but I'm not completely sure how to do it. At least I think that would fix the problem.
I would prefer to use Gmail, but since they use SSL encryption it might not work. I could just as easily use the Godaddy smtp server, if it would work.
I'd really appreciate some help. Thanks.