1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #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 <http://www.gnu.org/licenses/>.
-
- check_smtp() {
- hostname=$1
- port=$2
- if [ -z "$port" ]
- then
- port=587
- fi
- code=$(nc -q0 "$hostname" "$port" < /dev/null | cut -d " " -f1)
- if [ "$code" = "220" ]
- then
- success "SMTP@$hostname server replied 220 status"
- else
- fail "Unexpected reply from smtp@$hostname '$code'"
- fi
- }
-
- check_smtp_id() {
- hostname=$1
- idstr=$2
- port=$3
- if [ -z "$port" ]
- then
- port=587
- fi
- rep=$(nc -q0 "$hostname" "$port" < /dev/null)
- if echo "$rep" | grep -e "^220 $idstr" > /dev/null
- then
- success "SMTP@$hostname server replie '$idstr'"
- else
- fail "Unexpected reply from smtp@$hostname '$rep'"
- fi
- }
-
- check_imaps() {
- hostname=$1
- port=$2
- if [ -z "$port" ]
- then
- port=993
- fi
- rep=$(echo "01 LOGOUT" | openssl s_client -quiet -verify_quiet -connect "${hostname}:$port" -servername "$hostname")
-
- if echo "$rep" | grep "^01 OK" > /dev/null
- then
- success "IMAPS@$hostname '$(echo "$rep" | grep "^01 OK")'"
- else
- fail "Unexpected reply from imaps@$hostname '$rep'"
- fi
- }
|