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."
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
MAILSPOOL=/var/spool/mail/root
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
# make shure spool file is empty
Christoph Galuschka 0c087a
cat /dev/null > $MAILSPOOL
Christoph Galuschka 0c087a
ret_val=1
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
# send mail to localhost
b76322
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"
Christoph Galuschka 0c087a
if [ $? = 0 ]
Christoph Galuschka 0c087a
  then
Christoph Galuschka 0c087a
  t_Log 'Mail has been queued successfully'
Christoph Galuschka 0c087a
  MTA_ACCEPT=0
Christoph Galuschka 0c087a
fi
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
sleep 1
Christoph Galuschka 0c087a
grep -q 't_functional test' $MAILSPOOL
Christoph Galuschka 0c087a
if [ $? = 0 ]
Christoph Galuschka 0c087a
  then
Christoph Galuschka 0c087a
  t_Log 'previously sent mail is in '$MAILSPOOL
Christoph Galuschka 0c087a
  SPOOLFILE=0
Christoph Galuschka 0c087a
fi
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
if ([ $MTA_ACCEPT = 0  ] && [ $SPOOLFILE = 0 ])
Christoph Galuschka 0c087a
  then
Christoph Galuschka 0c087a
  ret_val=0
Christoph Galuschka 0c087a
fi
Christoph Galuschka 0c087a
Christoph Galuschka 0c087a
t_CheckExitStatus $ret_val
Christoph Galuschka 0c087a