Run a command and email the output, with a subject, using msmtp
0
votes
1
answer
2323
views
I have OpenWRT router, installed
msmtp
. I would like to write a command line (or a .sh file) that would send me the current public IP address, and let cron
execute it every 15 Min.
I found the posting: https://unix.stackexchange.com/questions/537082/run-a-command-and-email-the-output
and tried to do the same with msmtp
, and it did work: I did the following
kdig +short myip.opendns.com @resolver1.opendns.com | msmtp
xxxxxxxx@gmail.com
and got an email with the current public IP address, but without a subject, of course, because I didn't set anything. Now, for msmtp
, the way to put a subject is
echo "Subject: Current Public IP" | msmtp xxxxxxx@gmail.com
But I have no idea how I could combine these two things.... I would appreciate your help very much !
Asked by jbweld
(1 rep)
Aug 17, 2021, 08:14 PM
Last activity: Jun 11, 2025, 10:04 AM
Last activity: Jun 11, 2025, 10:04 AM