NAME

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

VERSION

Version 1.01

SYNOPSIS

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

my $channel = new App::MonM::Notifier::Channel;

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

my $ch_conf = {
    'fri' => '18:01-19',
    'from' => 'root@example.com',
    'host' => 'mail.example.com',
    'mon' => '7:35-17:45',
    'period' => '7:30-16:30',
    'port' => '25',
    'set' => [
      'User TeStUser',
      'Password MyPassword'
    ],
    'sun' => '-',
    'thu' => '16-18:01',
    'to' => 'test@example.com',
    'tue' => '15-19',
    'type' => 'Email',
    'wed' => '-'
};

my $status = $channel->process($data, $ch_conf);
die($channel->error) unless $channel->status;

DESCRIPTION

This module provides channel base methods

new

my $channel = new App::MonM::Notifier::Channel;

Returns the channel object

cleanup

my $self = $channel->cleanup;

Cleaning up of working variables

config

my $conf_hash = $channel->config;

Returns the channel configuration ($ch_conf)

data

my $data = $channel->data;
my $data = $channel->data( { ... } );

Sets/gets data structure

error

my $error = $channel->error;
my $error = $channel->error( "New error" );

Sets/gets error message

genId

my $message_id = $self->genId(
        $self->data->{id} || 0,
        $self->data->{pubdate} || 0,
        $self->data->{to} || "anonymous",
    );

Return ID of message

message

my $email = $channel->message;
my $email = $channel->message( new Email::MIME );

Gets/sets the Email::MIME object

process

my $status = $channel->process( $data, $ch_conf )
    or die($channel->error);

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

See "DATA" and "DIRECTIVES" for details

status

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

Get/set BOOL status of the operation

type

my $type = $channel->type;
my $type = $channel->type( "File" );

Gets/sets the type value

DATA

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

'data' => {
    'channel'   => "MyEmail",
    'comment'   => "Comment",
    'errcode'   => 0,
    'errmsg'    => 'Ok',
    'expires'   => 1565599719,
    'id'        => 31,
    'message'   => "Message body",
    'pubdate'   => 1563007719,
    'status'    => 'NEW',
    'subject'   => "My message",
    'to'        => 'testuser'
}
channel

Channel name

comment

Comment string

errcode

Error code

errmsg

Error message

expires

Expires time value

id

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

message

Body of the message

pubdate

The time of message publication

status

Status of record (text formst). See App::MonM::Notifier::Const

subject

Subject of the message

to

Recipient address or name

DIRECTIVES

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

Charset

Sets the charset

Default: utf-8

See also Email::MIME

ContentType

Sets the content type

Default: text/plain

See also Email::MIME

Encoding

Sets encoding (8bit, base64, quoted-printable)

Default: 8bit

See also Email::MIME

Headers

Container for MIME headers definitions

Type

Defines type of channel

Allowed types: File, Command, Email

HISTORY

See Changes file

DEPENDENCIES

CTK, App::MonM, Email::MIME

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

Email::MIME

AUTHOR

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

COPYRIGHT

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

LICENSE

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

See LICENSE file and https://dev.perl.org/licenses/