Blame tests/p_postfix/20_postfix_mta.sh

Christoph Galuschka 384d96
#!/bin/sh
Christoph Galuschka 384d96
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 384d96
Christoph Galuschka 384d96
t_Log "Running $0 - postfix can accept and deliver local email."
40b4c8
40b4c8
if [ "$CONTAINERTEST" -eq "1" ]; then
40b4c8
    t_Log "Running in container -> SKIP"
40b4c8
    exit 0
40b4c8
fi
40b4c8
baf472
ret_val=1
Christoph Galuschka 384d96
Christoph Galuschka 384d96
# send mail to localhost
19a135
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 queued)
65a551
MTA_ACCEPT=$?
65a551
if [ $MTA_ACCEPT == 0 ]
Christoph Galuschka 384d96
  then
Christoph Galuschka 384d96
  t_Log 'Mail has been queued successfully'
Christoph Galuschka 384d96
fi
Christoph Galuschka 384d96
Christoph Galuschka 384d96
sleep 1
2539f0
2539f0
if [ "$centos_ver" -eq "8" ]; then
2539f0
  t_Log "Dumping journalctl to /var/log/maillog"
2539f0
  journalctl -u postfix >> /var/log/maillog
2539f0
fi
2539f0
c49572
regex='250\ 2\.0\.0\ Ok\:\ queued\ as\ ([0-9A-Z]*).*'
c49572
if [[ $mail =~ $regex ]]
Christoph Galuschka 384d96
  then
c49572
  grep -q "${BASH_REMATCH[1]}: removed" /var/log/maillog
c49572
  DELIVERED=$?
Christoph Galuschka 384d96
fi
Christoph Galuschka 384d96
8efeaa
if ([ $MTA_ACCEPT == 0  ] && [ $DELIVERED == 0 ])
Christoph Galuschka 384d96
  then
Christoph Galuschka 384d96
  ret_val=0
c49572
  t_Log 'Mail has been delivered and removed from queue.'
Christoph Galuschka 384d96
fi
Christoph Galuschka 384d96
Christoph Galuschka 384d96
t_CheckExitStatus $ret_val