#!/bin/sh
#
# inflex_mail_deliver
#
# Delivers (if required) the email
#
# This script is designed for Inflex v2.x.x.x
# For earlier versions of Inflex, a direct hack
#	or replacement of the Inflex script is required
# 
#
# POSTFIX VERSION ----

#
# Some basic house keeping... if the file was all okay, we remove it
# else we leave it there for the administrator to "check out"
#
if [ $emailblocked -eq 0 ]; then

	#
	# Now that all is well and we're happy with the way things are
	# we can send off the email to its required destination.
	# NOTE - we use the servers NORMAL /etc/sendmail.cf file
	#
	#
	# Select the mailer that you are going to use to send mail out
	#
	# By default sendmail is selected
	#
	# Exim is supposed to be command line compatible with sendmail, so
	#  that is why it appears here initially.
	#

	# (v1.0.9)
	# does the user want a custom X-header.
	#
	if [ "a${appendXheader}" != "an" ]
	then
		$altermime --input=$tmpdir/mailpack --xheader="$Xheader"
	fi

	# (v1.0.9)
	# Add in a disclaimer if wanted, note there is the HTML body
	# option as well!
	#
	if [ "a$useDisclaimer" != "an" ]
	then
		#
		# First, check to see that the sender is from the local domain...
		#
		islocal=`printf "$sender\n" | grep "@$localdomain" | wc -l`
		if [ $islocal -gt 0 ]
		then
			$altermime --input=$tmpdir/mailpack --htmltoo --disclaimer=$disclaimer
		fi
	fi

	# POSTFIX DELIVERY REQUIRES THE USE OF THE mailfeeder PROGRAM
	#
	
	./mailfeeder -i ${tmpdir}/mailpack -S localhost -d localhost -p 10025 -s ${sender}  -r "${receivers}"
	exitstatus=$?

fi

#VERSION 2.0.0.0
