The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Transform::Alert::Input::IMAP - Transform alerts from IMAP messages

SYNOPSIS

    # In your configuration
    <Input test>
       Type      IMAP
       Interval  60  # seconds (default)
 
       <ConnOpts>
          ParsedFolder  Finished
 
          # See Mail::IMAPClient Parameters
          Server   mail.foobar.org
          User     bob
          Password mail4fun
          Folder   Inbox
          Uid      1
          # ...etc...
       </ConnOpts>
       # <Template> tags...
    </Input>

DESCRIPTION

This input type will read a IMAP mailbox and process each message through the input template engine. If it finds a match, the results of the match are sent to one or more outputs, depending on the group configuration.

See Mail::IMAPClient for a list of the ConnOpts section parameters.

The ParsedFolder option is special. If set, it will move all parsed messages to that folder. If not, it will rely on the Unread flag to figure out which messages have been parsed or not parsed.

The Folder option (from Mail::IMAPClient) can be specified to use a different folder than the default Inbox.

OUTPUTS

Text

Full text of the raw message, including headers. All CRs are stripped.

Preparsed Hash

    {
       # Header pairs, as per Email::Simple::Header
       Email::Simple->new($msg)->header_obj->header_pairs,
 
       # decoded via Email::MIME->new($msg)
       # $pmsg->body_str, or body_str of the first text/plain part (if it croaks), or $pmsg->body_raw
       # (all \r are stripped)
       BODY => $str,
    }

CAVEATS

Special care should be made when using input templates on raw email messages. For one, header order may change, which is difficult to manage with REs. For another, the message is probably MIME-encoded and would contain 80-character splits. Use of Mungers here is highly recommended.

You are responsible for setting up any archiving/deletion protocols for the mailbox, as this module will save everything (and potentially fill up the box).

The raw message isn't kept for the Munger. If you really need it, you can implement an input RE template of (?<RAWMSG>[\s\S]+), and parse out the email message yourself.

This class is persistent, keeping the Mail::IMAPClient object until shutdown. However, it will still disconnect on close, and will clear the object on error.

AVAILABILITY

The project homepage is https://github.com/SineSwiper/Transform-Alert/wiki.

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/Transform::Alert/.

AUTHOR

Brendan Byrd <BBYRD@CPAN.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2013 by Brendan Byrd.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)