Blame tests/p_sendmail/30_sendmail_mta_ehlo.sh

1dfe80
#!/bin/sh
Christoph Galuschka 2a3519
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 2a3519
1dfe80
t_Log "Running $0 - sendmail can accept and deliver local email."
Christoph Galuschka 2a3519
Christoph Galuschka 2a3519
# send mail to localhost
1dfe80
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 accepted)
1dfe80
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
1dfe80
regex='250\ 2\.0\.0\ ([0-9A-Za-z]*)\ Message\ accepted\ for\ delivery'
c6cf39
if [[ $mail =~ $regex ]]
Christoph Galuschka 2a3519
  then
1dfe80
  egrep -q "${BASH_REMATCH[1]}\:.*stat\=Sent" /var/log/maillog
c6cf39
  DELIVERED=$?
Christoph Galuschka 2a3519
fi
Christoph Galuschka 2a3519
1dfe80
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