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."
40b4c8
if [ "$CONTAINERTEST" -eq "1" ]; then
40b4c8
    t_Log "Running in container -> SKIP"
40b4c8
    exit 0
40b4c8
fi
baf472
ret_val=1
Christoph Galuschka 2a3519
Christoph Galuschka 2a3519
# send mail to localhost
19a135
mail=$(echo -e "ehlo 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 2a3519
  then
Christoph Galuschka 2a3519
  t_Log 'Mail has been queued successfully'
Christoph Galuschka 2a3519
fi
Christoph Galuschka 2a3519
c6cf39
sleep 1
834d5e
834d5e
if [ "$centos_ver" -eq "8" ]; then
834d5e
  t_Log "Dumping journalctl to /var/log/maillog"
834d5e
  journalctl -u sendmail >> /var/log/maillog
834d5e
fi
834d5e
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