Blame tests/p_postfix/30_postfix_mta_ehlo.sh

Christoph Galuschka 01a954
#!/bin/sh
Christoph Galuschka 01a954
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 01a954
Christoph Galuschka 01a954
t_Log "Running $0 - postfix can accept and deliver local email using ESMTP."
Christoph Galuschka 01a954
Christoph Galuschka 01a954
# send mail to localhost
c49572
mail=$(echo -e "ehlo localhost\nmail from: root@localhost\nrcpt to: root@localhost\ndata\nt_functional test\n.\nquit\n" | nc -w 5 localhost 25 | grep queued)
Christoph Galuschka 01a954
if [ $? = 0 ]
Christoph Galuschka 01a954
  then
Christoph Galuschka 01a954
  t_Log 'Mail has been queued successfully'
Christoph Galuschka 01a954
  MTA_ACCEPT=0
Christoph Galuschka 01a954
fi
Christoph Galuschka 01a954
Christoph Galuschka 01a954
sleep 1
c49572
regex='250\ 2\.0\.0\ Ok\:\ queued\ as\ ([0-9A-Z]*).*'
c49572
if [[ $mail =~ $regex ]]
Christoph Galuschka 01a954
  then
c49572
  grep -q "${BASH_REMATCH[1]}: removed" /var/log/maillog
c49572
  DELIVERED=$?
Christoph Galuschka 01a954
fi
Christoph Galuschka 01a954
c49572
if ([ $MTA_ACCEPT = 0  ] && [ $DELIVERED = 0 ])
Christoph Galuschka 01a954
  then
Christoph Galuschka 01a954
  ret_val=0
c49572
  t_Log 'Mail has been delivered and removed from queue.'
Christoph Galuschka 01a954
fi
Christoph Galuschka 01a954
Christoph Galuschka 01a954
t_CheckExitStatus $ret_val