Mail::Action - base for building modules that act on incoming mail
use base 'Mail::Action';
E-mail doesn't have to be boring. If you have server-side filters, a bit of disk space, some cleverness, and access to an outgoing SMTP server, you can do some very clever things. Want a temporary mailing list? Try Mail::SimpleList. Want a temporary, mostly-anonymous mailing address? Try Mail::TempAddress. Want to build your own similar program? Read on.
Mail::Action, Mail::Action::Address, Mail::Action::Request, and Mail::Action::Storage make it easy to create a other modules that receive, filter, and respond to incoming e-mails.
new( $address_directory, [ Filehandle => $fh, Storage => $storage, Request => $request ] )
new()takes one mandatory argument and three optional arguments.
$address_directoryis the path to the directory where address data is stored. You can usually get by with just the mandatory argument.
$fhis a filehandle (or a reference to a glob) from which to read an incoming message. If not provided, M::TA will read from
STDIN, as that is how mail filters work.
$requestshould be a Mail::Action::Request object (representing and encapsulating an incoming e-mail message) to the constructor. If not provided, M::TA will use Mail::Action::Request by default.
Processes one incoming message.
Looks in the
Subjectheader of the incoming message for a command (a word contained within asterisks, such as
*help*. If it finds this, it checks to see if the current object can perform a method named
command_command, where command is the command found. If so, it returns the name of that method.
If not, it returns an empty string.
Copies, cleans, and returns a hash reference of headers from the incoming message.
command_help( $pod, @headings )
$pod, POD documentation, and
@headings, and list of headings within the POD, extracts the POD within those headings, turns it into plain text, and e-mails that text to the
Fromaddress of the incoming message.
process_body( $address )
Looks for lines of the form:
at the start of the body of the incoming message. If the
$addressobject (likely Mail::Action::Address or equivalent) understands the directive, this method calls the method with the name of the directive on the address object, passing the arguments.
This stops looking for directives when it encounters a blank line.
reply( $headers, @body )
Given a hash reference of e-mail
$headersand a list of lines of
@bodytext, sends a message via Mail::Mailer. Be sure you've configured that correctly.
In addition to the methods described earlier, you may want to override any of the other methods:
Attempts to retrieve the address for the associated alias, if it exists. In scalar context, returns just the address. In list context, returns the address and the alias. If the address does not exist, returns nothing.
Email::MIMEobject associated with this request.
Returns the request object for this object.
Returns the storage object for this object.
chromatic, <chromatic at wgz dot org<.
No known bugs.
Copyright (c) 2003 - 2009 chromatic. Some rights reserved. You may use, modify, and distribute this module under the same terms as Perl 5.10 itself.