Trying to mail msmtp server on wan conection

Hello agian,

im using wireguard and im trying to send a mail when wan has a new ip adress (i cant choose my ip:().
i made a file 90-led on the /etc/hotplug.d/iface folder. with:


check_if_wan_up="$(ip -br a | grep "$wan_iface" | grep UP)"
check_wan_IP="$(ip -br a | grep "$wan_iface" | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')"
if [ "$check_if_wan_up" != "" ] && [ "$check_wan_IP" != "" ]; then

tekst="$(echo "Subject: IP adress is Changed to:\r\n$check_wan_IP"|sed 's/$/:25565/')" 
echo "$tekst" | sendmail -a default "<MY EMAIL>"

a simple script that checks if wan is on then is there a ip adress.
if wan is not nothing and if ip_wan is not nothing then just email the ip adress of the wan.

But the mail i receive is the subject and the ip in the subject :frowning:
i'm trying to make it like subject: the new ip adress is:
and the body: (as a example)

the \r\n i changed for:


Im stuck because everything i search on google the syntax shows up, :blush: i really dont know where im looking for or how to fix it.

If u know the solution or the search terms on google please let my know.
thanks in advance

Time spend on this problem 3hours now

if [ ... ]; then
echo "$check_wan_IP" > /tmp/newip.txt
echo "Subject: The new IP adress is:" | sendmail < /tmp/newip.txt

1 Like

It can be this simple 🤦

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.