Sendmail not working as desired in bash script

Posted by dan08 on Ask Ubuntu See other posts from Ask Ubuntu or by dan08
Published on 2013-10-24T13:29:22Z Indexed on 2013/10/24 16:10 UTC
Read the original article Hit count: 340

Filed under:
|
|

This is the code I have in a bash script that runs as a cronjob. The cronjob run as root.

   /usr/sbin/sendmail [email protected]<<EOF
   subject:Backup Error!
   from:backup@server01
   $error
        EOF

There is code after this and the email I get is as follows:

From the root user on the machine.

and the message includes:

   subject:Backup Error!
   from:backup@server01
   $error
        EOF
   More code...
   that is in the script
   all the way to the end...

I have tried other variations, this is the closest I've got. I tried this in a regular script and it worked properly. Whats going on, and how can I send this email, specifying the subject and form sender?

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about scripts