NAME

Postfix::ContentFilter - a perl content_filter for postfix

VERSION

version 1.12

DESCRIPTION

Postfix::ContentFilter can be used for content_filter scripts, as described here: http://www.postfix.org/FILTER_README.html.

SYNOPSIS

    use Postfix::ContentFilter;

    $exitcode = Postfix::ContentFilter->process(sub{
	$entity = shift; # isa MIME::Entity
	
	# do something with $entity
	
	return $entity;
    });
    
    # Or specifying the parser
    my $cf = Postfix::ContentFilter->new({ parser => 'Mail::Message' });

    $exitcode = $cf->process(sub{
	$entity = shift; # isa Mail::Message
	
	# do something with $entity
	
	return $entity;
    });

    exit $exitcode;

METHODS

new($args)

new creates a new Postfix::Contentfilter. It takes an optional argument of a hash with the key 'parser', which specifies the parser to use as per footer. This can be either MIME::Entity or Mail::Message.

Alternatively process can be called directly.

parser($string)

parser() specifies the parser to use, which can be either MIME::Parser or Mail::Message. It defaults to MIME::Parser, if available, or Mail::Message whichever could be found first. When called without any arguments, it returns the current parser.

process($coderef [, $inputhandle])

process() reads the mail from STDIN (or $inputhandle, if given), parses it, calls the coderef and finally runs sendmail with our own command-line arguments (@ARGV).

This function returns the exitcode of sendmail.

VARIABLES

  • $sendmail

    $sendmail defaults to /usr/sbin/sendmail.

    $Postfix::ContentFilter::sendmail = [ '/usr/local/sbin/sendmail', '-G', '-i' ];

    Please note $sendmail must be an arrayref. Don't forget to use the proper arguments for sendmail, or just replace the first element in array.

    Additional arguments can be added with:

    push @$Postfix::ContentFilter::sendmail => '-t';
  • $output

    Any output from sendmail command is populated in $output.

  • $parser

    The MIME::Parser object is available via $parser. To tell where to put the things, use:

    $Postfix::ContentFilter::parser->output_under('/tmp');

CAVEATS

If taint mode is on, %ENV will be stripped:

delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV', 'PATH'}

So set $Postfix::ContentFilter::sendmail to an absolute path, if you are using taint mode. See perlsec(1) for more details about unsafe variables and tainted input.

SEE ALSO

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/zurborg/libpostfix-contentfilter-perl/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

David Zurborg <zurborg@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2014 by David Zurborg.

This is free software, licensed under:

The ISC License