Blame tests/p_sendmail/20_sendmail_mta.sh

Christoph Galuschka 0c087a
#!/bin/sh
Christoph Galuschka 0c087a
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
t_Log "Running $0 - sendmail can accept and deliver local email."
baf472
ret_val=1
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
# send mail to localhost
957f65
mail=$(echo -e "helo localhost\nmail from: root@localhost\nrcpt to: root@localhost\ndata\nt_functional test\n.\nquit\n" | nc -w 5 127.0.0.1 25 | grep accepted)
3bb82f
MTA_ACCEPT=$?
3bb82f
if [ $MTA_ACCEPT == 0 ]
Christoph Galuschka 0c087a
  then
Christoph Galuschka 0c087a
  t_Log 'Mail has been queued successfully'
Christoph Galuschka 0c087a
fi
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
sleep 1
1dfe80
regex='250\ 2\.0\.0\ ([0-9A-Za-z]*)\ Message\ accepted\ for\ delivery'
c6cf39
if [[ $mail =~ $regex ]]
Christoph Galuschka 0c087a
  then
1dfe80
  egrep -q "${BASH_REMATCH[1]}\:.*stat\=Sent" /var/log/maillog
c6cf39
  DELIVERED=$?
Christoph Galuschka 0c087a
fi
Christoph Galuschka 0c087a
1dfe80
if ([ $MTA_ACCEPT == 0  ] && [ $DELIVERED == 0 ])
Christoph Galuschka 0c087a
  then
Christoph Galuschka 0c087a
  ret_val=0
c6cf39
  t_Log 'Mail has been delivered and removed from queue.'
Christoph Galuschka 0c087a
fi
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
t_CheckExitStatus $ret_val