#!/bin/sh

if [ -z "${RELAYCLIENT+xxx}" ]; 
then

  if [ -z "${SMTPRCPTTO}" ];
  then
    echo "`basename $0`: blocked with: invalid RCPT TO syntax: $RCPTTO" 1>&2
    sleep 5
    echo "E553 sorry, mail to that recipient is not accepted (#5.7.1)"
    exit 1
  else
    RCPTTO=${SMTPRCPTTO}
  fi

  if echo "${RCPTTO}" | grep -qE ".+@.+\..+"
  then
  echo "ok"
    exit 0
  else
    echo "`basename $0`: blocked with: invalid RCPT TO syntax: $RCPTTO" 1>&2
    sleep 5
    echo "E553 sorry, mail to that recipient is not accepted (#5.7.1)"
    exit 1
  fi

fi

exit 0
