I'm trying to send an email using bash script.
I tried using the following in the bash script with no success as I execute the script it asks for CC:
#!/bin/bash
recipient="[email protected]"
mail -s "This is a test mail" "$recipient"
but nothing seems to work as I want it to be automated.
Also I want to send a message with the mail I went through different tutorials but in every tutorial a message is written in a text file then the file is sent but can't I write a message with the mail command itself and not save it to any file and send it. Please Help.
P.S.
I just want the script to do the following
If a particular operation is complete then it sends an email to the recipient with a subject and a message saying operation is completed successfully.
ls -l /etc/alternatives/mail
in your question? It's possible you have installed a differentmail
client than I have, so this makes it hard to verify answers. (I can provide an answer how to send a message with it from within the script, btw.)mailx
, but formail
, the command you're running. See also this answer: mail alternatives and the comments on it. Please edit your question for providing more information - this is not a discussion forum, but a Q&A site, you see.which mail | xargs dpkg -S
.