# $DUH: header_nofrom,v 1.4 2002/12/16 05:14:33 tv Exp $
#
# Copyright (c) 2002 Todd Vierling <tv@pobox.com> <tv@duh.org>.
# All rights reserved.
# Please see the COPYRIGHT file, part of the PMilter distribution,
# for full copyright and license terms.

##### header_nofrom #####
#
# Rejects messages missing a From: header.

my $errmsg = shift_errmsg(@_, 'From: header missing from message');

+{
	envfrom => sub {
		my $ctx = shift;

		$ctx->setpriv(undef);
		return SMFIS_CONTINUE;
	},

	header => sub {
		my $ctx = shift;
		my $name = shift;

		$ctx->setpriv(1) if (lc($name) eq 'from');
		return SMFIS_CONTINUE;
	},

	eoh => sub {
		my $ctx = shift;

		return ($ctx->getpriv ? SMFIS_CONTINUE : $ctx->reject("554 $errmsg"));
	}
};
