NAME

App::MonM::Notifier::Channel - monotifier channel base class

VERSION

Version 1.00

SYNOPSIS

use App::MonM::Notifier::Channel;

my $channel = new App::MonM::Notifier::Channel(
        timeout => 300, # Default: 300
    );

my $data = {
    id      => 1,
    to      => "recipient",
    from    => "sender",
    subject => "Test message",
    message => "Content of the message",
};

$channel->send( default => $data ) or warn($channel->error);
# ...or...
$channel->default( $data ) or warn($channel->error);

# Run Email::MIME methods
print $channel->{email}->body_str if $channel->status;

DESCRIPTION

This module provides channel base methods

METHODS

new
my $channel = new App::MonM::Notifier::Channel(
        timeout => 300, # Default: 300
    );

Constructor

The "timeout" attribute is maximum time to run the channel process. Default: 300 secs

status
my $status = $channel->status;
my $status = $channel->status( 1 ); # Sets the status value and returns it

Get/set BOOL status of the operation

error
my $error = $channel->error;

Gets error message

my $status = $channel->error( "Error message", "Trace dump" );

Sets error message and trace dump if second argument is provided. This method in "set" context returns status of the operation as status() method. See "trace" about tracing

trace
my $trace = $channel->trace;

Gets trace message

timeout
my $timeout = $channel->timeout;

# Sets the timeout value and returns it
my $timeout = $channel->timeout( 500 );

Get/set timeout of the operation

channels
my @available_channels = $channel->channels;
my $available_channel = $channel->channels( "default" );

Returns list of available channels. To check the availability of the channel, you must specify its name as an argument

check
my $status = $channel->check( file => $data, $opts )
    or warn($channel->error);

Runs validation of the data and options and returns status

send
my $status = $channel->send( default => $data, $opts )
    or warn($channel->error);
my $status = $channel->default( $data, $opts )
    or warn($channel->error);

This method runs process of sending message to selected channel and returns status this operation.

For selecting the channel you must be provided name it as the first argument or call the method of the same name.

See "DATA" and "OPTIONS" for more details on data and options of method

handler

Local default method that provides base process. See "send" method

DATA

It is a structure (hash), that can contain the following fields:

id

Contains internal ID of the message. This ID is converted to an X-Id header

to

Recipient address or name

from

Sender address or name

subject

Subject of the message

message

Body of the message

headers

Optional field. Contains eXtra headers (extension headers). For example:

headers => {
        "bcc" => "bcc\@example.com",
        "X-Mailer" => "My mailer",
    }

OPTIONS

It is a structure (hash), that can contain the following fields:

encoding

Encoding: 'quoted-printable', base64' or '8bit'

Default: 8bit

See Email::MIME

content_type

The content type

Default: text/plain

See Email::MIME

charset

Part of common Content-Type attribute. Defines charset

Default: utf-8

See Email::MIME

io

This attribute defines method of the returned serialized data

my $ret;
$channel->default( $data, {io => \$ret} );

Returns serialized data as scalar variable $ret

$channel->default( $data, {io => $fh} );

Returns serialized data to file by file handler (IO::File)

$channel->default( $data, {io => \*STDERR} );

Returns serialized data to STDERR pipe

$channel->default( $data, {io => IO::Pipe->new} );

Returns serialized data to custom pipe

$channel->default( $data, {io => 'NONE'} );

Returns serialized data to STDOUT

$channel->default( $data, {io => undef} );

No returns any serialized data! See email attrribute, get it via $channel->{email} access

signature

Set/unset add signature to the message's body

HISTORY

See CHANGES file

DEPENDENCIES

CTK, Email::MIME

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

App::MonM::Notifier, Email::MIME

AUTHOR

Sergey Lepenkov (Serz Minus) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2017 D&D Corporation. All Rights Reserved

LICENSE

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See LICENSE file