this is my old topic sSmtp send email with dynamic ip renew script, since ssmtp is no longer supported i cant use this.
current shell looks like this, but it doesnt work.
root@OpenWrt:~/bin# msmtp check_dynamic_ip.sh
^C
root@OpenWrt:~/bin# cat check_dynamic_ip.sh
FROM=sender@openwrt
HOSTNAME=$(cat /proc/sys/kernel/hostname)
MSG="$HOSTNAME IP change, please review"
MYIP=$(ifconfig pppoe-wan | grep 'inet addr'| awk '{print $2}' | cut -d ':' -f 2)
LASTIPFILE='/tmp/last_ip_addr'
if [ ! -f "$LASTIPFILE" ]
then
LASTIP="0.0.0.0"
else
LASTIP=$(cat ${LASTIPFILE})
fi
mailto ()
{
{
echo To: "$TO"
echo From: "$FROM"
echo Subject: "$MSG"
echo
echo "New IP = $MYIP"
} | msmtp -t < check_dynamic_ip.sh "$TO"
}
if [[ "${MYIP}" != "${LASTIP}" ]]; then
mailto
echo -n "${MYIP}" > "${LASTIPFILE}"
fi
root@OpenWrt:~/bin#
root@OpenWrt:~/bin# cat /etc/msmtprc
# Example for a system wide configuration file
# A system wide configuration file is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default
# The SMTP smarthost
host poczta.o2.pl
# Use TLS on port 465. On this port, TLS starts without STARTTLS.
port 465
auth on
user XXXXXX@o2.pl
password XXXXXXX
tls on
tls_starttls off
tls_certcheck off
# Construct envelope-from addresses of the form "user@oursite.example"
from XXXXXXXX@o2.pl
# Do not allow programs to override this envelope-from address via -f
allow_from_override off
# Always set a From header that matches the envelope-from address
set_from_header on
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL
logfileroot@OpenWrt:~/bin#
My ISP renews connection after 14400 minutes for some reason, no-ip.com crying after renewal after 30 days. in case i forget renew ddns hostname this will be me second backup.
This script is wrong since, msmtp requires separate file to read