Try#1:
#!/bin/sh
now=$(date +'%m/%d/%Y %T');
#default values
sendto="anam.akhmad@gmail.com"
subject="[automail]IP Notification "${now}""
from="Paman Gober"
errorsfile=/tmp/ssmtp.error
getIP=$(wget http://ipecho.net/plain -O - -q ; echo);
#getIP2=curl ipecho.net/plain; echo
#getIP3=curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
#getIP4=curl icanhazip.com
header="Subject: ${subject}\nFrom:${from}\nTo:${sendto}\n"
content="Info dari gober\n\nIP server saat ini ${getIP}\nPeringatan!!.Setelah menerima pesan ini mohon di hapus segera dari email anda \n\nSalam dari Gober"
# workaround for the 'sh echo' not handling -e
if [ -n "$(/bin/sh -c 'echo -ne')" ]; then
echocmd=echo
else
echocmd=echo\ -e
fi
$echocmd "${header}${content}" | ssmtp "${sendto}" 2>>${errorsfile}
exit $?
No comments
Post a Comment