SMTP AUTHを自動テストするためのシェルスクリプトです。
使用法:SASL_test.sh <usetname> <password>
▼SASL_test.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#!/bin/sh ######################################## # Postfix SASL Test Script ######################################## #debug="debug" # debug option debug="" # no debug # ------------------------------------------------------------------------ if [ -z $2 ] ; then echo "Usage: SASL_test.sh <username> <password>" exit 1 fi PRE_SLEEP=2 POST_SLEEP=3 SMTPSERVER=localhost MYDOMAIN=localhost.localdomain USER=$1 PASS=$2 ENPASS=`perl -MMIME::Base64 -e \ "printencode_base64(\"$USER\0$USER\0$PASS\");"` echo $PASS | saslpasswd -p -c -u `postconf -h myhostname` $USER if [ "x$debug" = "xdebug" ] ; then sasldblistusers fi ( echo "EHLO $MYDOMAIN" echo "AUTH PLAIN $ENPASS" echo "QUIT" ) | while read cmd ; do sleep $PRE_SLEEP echo $cmd 1>&2 echo $cmd sleep $POST_SLEEP done | telnet $SMTPSERVER smtp 2>&1 | tee result.$$ echo "#" if grep "235 Authentication successful" result.$$ ; then echo "Test Ok! Congratulations." else echo "Test NG. Check your setting." fi rm -f result.$$ saslpasswd -d -u `postconf -h myhostname` $USER if [ "x$debug" = "xdebug" ] ; then sasldblistusers fi exit 1 |