简体   繁体   中英

how to send an email when creating a bash script

I'm trying to create a bash script that will send me an email every time it pings an IP address. When I run the script I get and error saying

bash: sendmail: command not found

Here is my code

while true; do

    ping my_ip_address


    echo "some message" | sendmail -s "test" "test@test.com"
    sleep 20
done

and this is my sendmail.ini file

smtp_server=smtp.mailtrap.io
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=f1e1ea69338455
auth_password=97ce281bfdb99f
pop3_server=pop3.mailtrap.io
pop3_username=f1e1ea69338455
pop3_password=97ce281bfdb99f
force_sender=
force_recipient=
hostname=

I have my sendmail.ini saved in C:\sendmail\

Looks like sendmail is not in your $PATH .

Try to either add directory with sendmail to your $PATH or use full path to sendmail.

Edit: Also remove credentials from your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM