I am using msmtp to send an email with the output from a cron job (rsync) on my Manjaro setup on my Macbook Air.
Like this:
38 20 * * * /home/tony/rsync/rsync_macbookair.sh 2>&1 | msmtp -a myemail@gmail.com myemail@gmail.com
While it does send the output to my gmail account, it comes in with no subject.
Is there a way to add the cron job as a subject when used like this above?
On another system I use ssmtp and the cron MAILTO=myemail@gmail.com and I get the subject line.
Thanks
Its difficult to say without knowing what the output of rsync_macboocair.sh
is.
Ostensibly you should just need it included, ex;
$(printf "Subject: Test\n\nSome Message." && /home/tony/rsync/rsync_macbookair.sh 2>&1) | msmtp -a myemail@gmail.com myemail@gmail.com
or
/home/tony/rsync/rsync_macbookair.sh 2>&1 | {
SUBJ="A Subject"
echo "From: \"name\"<myemail@gmail.com>"
echo "To: \"me\"<myemail@gmail.com>"
echo "Subject: ${SUBJ}"
cat /dev/fd/0
} | msmtp myemail@gmail.com
Thank you cscs - it works from the command line, so I guess I can put it into another bash script and use it in cron?
It does work in cron when used in a bash script.
Many thanks!
system
Closed
7 June 2023 19:40
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.