Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mail command not found error while script execution [closed]

below is the code which I am working on, I am trying to trigger the mail when it enters the if block

#!/bin/bash
toaddr2="[email protected]"
# Main Routine
export PATH=/usr/bin:/usr/local/bin
ssh -o PasswordAuthentication=no -q [email protected] exit
test=$?
echo "return value  is $test"

set PATH=/usr/bin:$PATH
mail $toaddr2 -s "THIS IS THE SUBJECT"

When I execute the above code, i am getting mail command not found I am using bash and tried setting up the path as well.

I tried with mailx command as well, got the same error Not worked, any clue from any one, what might be the issue.

like image 670
gmhk Avatar asked Nov 17 '25 17:11

gmhk


1 Answers

You can start with:

which mail

If it is in your path you can have the full path to it in bash. You could also attempt to use

 locate 

To find mail on your machine.

like image 180
cody Avatar answered Nov 19 '25 09:11

cody



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!