NAME

Mail::Postfix::Postdrop - Inject mails to a Postfix maildrop directory

SYNOPSIS

# Functional interface
use Mail::PostFix::Postdrop 'inject';

inject $message, Sender     => 'alice@example.net',
                 Recipients => [ qw(bob@example.com carol@example.net) ];


# OOish interface

my $postdrop = new Mail::Postfix::Postdrop $message;

$postdrop->build;    # Build the content of the queue file 
$postdrop->write;    # Write it to the maildrop queue
$postdrop->release;  # Let pickup(8) process the queue file
$postdrop->notify;   # Notify pickup(8) about new files (Optional)

DESCRIPTION

Bone::Mail::Postfix::Postdrop implements parts of postfix's postdrop(1) utility. Using the functionel interface you can inject messages directly into the maildrop queu and using the OOish interface you can control parts of the process.

The main use case is writing the mail to a queue where postfix will take the responsability to deliver the mail without letting postfix handle the mail immediately. This can be used for sending mails in transactions.

FUNCTIONS

inject

inject $message, %overrides;

Given a message, either as a Email::Abstract object or as something Email::Abstract->new() will process (like a string), this function will inject the mail into Postfix's maildrop queue. If not overridden sender and recipients will be extracted from the message.

The following overrides is supported:

Sender (string)

Default: content of the Sender or From header

Recipients (arrayref)

Default: content of To, CC, and BCc headers.

Attr (hashref)

Attributes to further posfix processing. Default:

{ rewrite_context => 'local' }
                                           

METHODS

The following methods is supported:

new

Takes the same arguments as the inject function without injecting the mail immediately.

build

Builds the queue content. If you change the content you'll have to call build again or you will inject old mail. Returns a string containing the queue content.

write

Write the content to a maildrop file. Returns a false value on failure and sets $! arcordingly.

release

Releases the queue file so pickup(8) will indeed pick it up next time it scans the maildrop queue.

notify

Notifies pickup(8) that new mail has been placed in the maildrop queue. By calling this function you mail should be processed immediately otherwise pickup should automatically scan the queue each minute.

check

Checks if the queue file still exists. Notice that notify is nonblocking and on a loaded system it may take a while for the mail to be processed. There is also a minor chance that some other mail with the same name might be generated in the mean time.

BUGS AND INCONVENIENCES

To use this module you script have to run in the postdrop group.

Please report any bugs or feature requests to bug-mail-postfix-postdrop at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mail-Postfix-Postdrop. I will be notified, and then you'll automatically be notified of progress on your bug as I make chang

TODO

It would be nice to restore the ability from Qpsmtpd::Postfix to talk directly to the cleanup(8)-daemon.

AUTHOR

Peter Makholm, <makholm at one.com>

COPYRIGHT & LICENSE

Copyright 2008 One.com, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

ACKNOWLEDGEMENTS

Partly based on Qpsmptd::Postfix by Ask Bjoern Hansen, Develooper LCC

# vim:sw=2