#Copyright (C) 2016,2023 Weber Yann # #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation; either version 3 of the License, or #any later version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program. If not, see . check_smtp() { hostname=$1 port=$2 ipv_arg=$3 if [ -z "$port" ] then port=587 fi case "$ipv_arg" in ipv4)ipv=-4;; ipv6)ipv=-6;; *)ipv="";; esac code=$(nc $ipv -q0 "$hostname" "$port" < /dev/null | cut -d " " -f1) if [ "$code" = "220" ] then success "SMTP@$hostname $ipv_arg server replied 220 status" else fail "Unexpected reply from smtp@$hostname $ipv_arg '$code'" fi } check_smtp_id() { hostname=$1 idstr=$2 port=$3 ipv=$4 if [ -z "$port" ] then port=587 fi case "$ipv_arg" in ipv4)ipv=-4;; ipv6)ipv=-6;; *)ipv="";; esac rep=$(nc $ipv -q0 "$hostname" "$port" < /dev/null) if echo "$rep" | grep -e "^220 $idstr" > /dev/null then success "SMTP@$hostname $ipv_arg server replie '$idstr'" else fail "Unexpected reply from smtp@$hostname $ipv_arg '$rep'" fi } check_imaps() { hostname=$1 port=$2 ipv=$3 if [ -z "$port" ] then port=993 fi case "$ipv_arg" in ipv4)ipv=-4;; ipv6)ipv=-6;; *)ipv="";; esac rep=$(echo "01 LOGOUT" | openssl s_client $ipv -quiet -verify_quiet -connect "${hostname}:$port" -servername "$hostname") if echo "$rep" | grep "^01 OK" > /dev/null then success "IMAPS@$hostname $ipv_arg '$(echo "$rep" | grep "^01 OK")'" else fail "Unexpected reply from imaps@$hostname $ipv_arg '$rep'" fi }