Msmtp, cron and gmail

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/ 2>&1 | msmtp -a

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 and I get the subject line.

Its difficult to say without knowing what the output of is.
Ostensibly you should just need it included, ex;

$(printf "Subject: Test\n\nSome Message." && /home/tony/rsync/ 2>&1)  | msmtp -a


/home/tony/rsync/ 2>&1 | {
    SUBJ="A Subject"
    echo "From: \"name\"<>"
    echo "To: \"me\"<>"
    echo "Subject: ${SUBJ}"
    cat /dev/fd/0
} | msmtp 

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!

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