Blame tests/p_sendmail/30_sendmail_mta_ehlo.sh

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