0

I apologize if this is a dumb/redundant question.

I have an Ubuntu Server 16.04, main use is as a test environment and learning experience. I have SSH setup on this server that runs fine. I have mailutils ssmtp installed to use a cron job to send me an email every day with my external IP. I'm too lazy/cheap at this point to setup a static IP.

Whenever I get this email, it automatically BCCs address@servername and ip@servername. I can't seem to figure out where/why this is happening.

Below is the script I'm using.

Code is borrowed from another source not my own.

#!/bin/sh

SUBJ="Server IP Address"
EMAIL="email@gmail.com"

ip2=""

ip2=$(wget -qO- ifconfig.me/ip)

echo "$ip2" | mail -s $SUBJ $EMAIL
exit
fi

I also have this issue when Logwatch sends out the report email except to root@servername.

Please let me know if I am neglecting to give more information or if this is just really dumb.

I tried to check for a possible fix already but might have missed it due to wording. Thank you for your help.

Robby1212
  • 870
  • 1
  • 10
  • 26

1 Answers1

0

Found the fix when trying to fix something else, funny how that works.

#!/bin/sh

(wget -qO- ifconfig.me/ip) > ip.txt

mail -s "HomeOne IP Address" sarvis.server1@gmail.com < ip.txt 

For whatever reason the variables in the bash script were causing the mail to weird out and try and send it to strange and nonexistent email addresses.

Robby1212
  • 870
  • 1
  • 10
  • 26