如何检查电子邮件是否已成功在Bash中传递?

时间:2018-11-20 20:19:59

标签: bash email

email_process=`echo -e "$BODY" | email -html -timeout 20 -V -s "$HEADER" "$USER_ADDRESS"`
if [[ "$email_process" == *"Sending"*"100% of"* ]]; then
    echo "   > successfully delivered";
fi

我尝试这个。但是此代码不起作用。因为email_process=Connecting to server smtp.gmail.com on port 587 变量email_process必须等于

Connecting to server smtp.gmail.com on port 587
Sending  "test_text"  |********| 100% of 366 Bytes
Sending QUIT...

1 个答案:

答案 0 :(得分:0)

wget -q --spider http://google.com
if [ $? -eq 0 ]; then
    echo "Online"
else
    echo "Offline"
fi

我先尝试过此操作,然后再发送电子邮件。