From c6cf39a00aa66f2998efc439b5503e6512af442f Mon Sep 17 00:00:00 2001 From: Christoph Galuschka Date: Oct 03 2014 18:53:44 +0000 Subject: sendmail now also uses maillog to verify local mail delivery --- diff --git a/tests/p_sendmail/20_sendmail_mta.sh b/tests/p_sendmail/20_sendmail_mta.sh index 38d4fbe..437a054 100755 --- a/tests/p_sendmail/20_sendmail_mta.sh +++ b/tests/p_sendmail/20_sendmail_mta.sh @@ -3,14 +3,8 @@ t_Log "Running $0 - sendmail can accept and deliver local email." -MAILSPOOL=/var/spool/mail/root - -# make shure spool file is empty -cat /dev/null > $MAILSPOOL -ret_val=1 - # send mail to localhost -echo -e "helo localhost\nmail from: root@localhost\nrcpt to: root@localhost\ndata\nt_functional test\n.\nquit\n" | nc -4 -w 5 localhost 25 | grep -q "250 2.0.0" +mail=$(echo -e "helo localhost\nmail from: root@localhost\nrcpt to: root@localhost\ndata\nt_functional test\n.\nquit\n" | nc -w 5 localhost 25 | grep queued) if [ $? = 0 ] then t_Log 'Mail has been queued successfully' @@ -18,16 +12,17 @@ if [ $? = 0 ] fi sleep 1 -grep -q 't_functional test' $MAILSPOOL -if [ $? = 0 ] +regex='250\ 2\.0\.0\ Ok\:\ queued\ as\ ([0-9A-Z]*).*' +if [[ $mail =~ $regex ]] then - t_Log 'previously sent mail is in '$MAILSPOOL - SPOOLFILE=0 + grep -q "${BASH_REMATCH[1]}: removed" /var/log/maillog + DELIVERED=$? fi -if ([ $MTA_ACCEPT = 0 ] && [ $SPOOLFILE = 0 ]) +if ([ $MTA_ACCEPT = 0 ] && [ $DELIVERED = 0 ]) then ret_val=0 + t_Log 'Mail has been delivered and removed from queue.' fi t_CheckExitStatus $ret_val diff --git a/tests/p_sendmail/30_sendmail_mta_ehlo.sh b/tests/p_sendmail/30_sendmail_mta_ehlo.sh index 7d9df26..fda5581 100755 --- a/tests/p_sendmail/30_sendmail_mta_ehlo.sh +++ b/tests/p_sendmail/30_sendmail_mta_ehlo.sh @@ -3,30 +3,27 @@ t_Log "Running $0 - sendmail can accept and deliver local email using ESMTP." -MAILSPOOL="/var/spool/mail/root" - -# make shure spool file is empty -cat /dev/null > ${MAILSPOOL} -ret_val=1 - # send mail to localhost -echo -e "ehlo localhost\nmail from: root@localhost\nrcpt to: root@localhost\ndata\nt_functional test\n.\nquit\n" | nc -4 -w 5 localhost 25 | grep -q "250 2.0.0" -if [ "$?" = "0" ] +mail=$(echo -e "ehlo localhost\nmail from: root@localhost\nrcpt to: root@localho +st\ndata\nt_functional test\n.\nquit\n" | nc -w 5 localhost 25 | grep queued) +if [ $? = 0 ] then t_Log 'Mail has been queued successfully' - MTA_ACCEPT="0" + MTA_ACCEPT=0 fi -sleep 3 -grep -q 't_functional test' ${MAILSPOOL} -if [ "$?" = "0" ] +sleep 1 +regex='250\ 2\.0\.0\ Ok\:\ queued\ as\ ([0-9A-Z]*).*' +if [[ $mail =~ $regex ]] then - t_Log "previously sent mail is in ${MAILSPOOL}" - SPOOLFILE="0" + grep -q "${BASH_REMATCH[1]}: removed" /var/log/maillog + DELIVERED=$? fi -if [[ "$MTA_ACCEPT" = "0" && "$SPOOLFILE" = "0" ]] ; then +if ([ $MTA_ACCEPT = 0 ] && [ $DELIVERED = 0 ]) + then ret_val=0 + t_Log 'Mail has been delivered and removed from queue.' fi t_CheckExitStatus $ret_val