NAME

App::MonM::Notifier::Channel::Email - monotifier email channel

VERSION

Version 1.00

SYNOPSIS

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

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

# Send message via email channel
$channel->email(
    {
        id      => 1,
        to      => "anonymous\@example.com",
        from    => "root\@example.com",
        subject => "Test message",
        message => "Content of the message",
        headers => {
                   "X-Foo"	=> "Extended eXtra value",
            },
    },
    {
        encoding => 'base64', # Default: 8bit
        content_type => undef, # Default: text/plain
        charset => undef, # Default: utf-8

        # SMTP options
        host    => '127.0.0.1', # Default: localhost
        port    => 25, # Default: 25

        # General options
        timeout => 120, # Default: 120
        helo    => 'host.example.com', # Default: undef

        # SASL & SSL options
        #username    => '', # Default: undef
        #password    => '', # Default: undef
        ssl         => 0, # Default: undef
        ssl_options => {}, # Default: undef
    }) or warn( $channel->error );

# See error
print $channel->error unless $channel->status;

# Also see trace for error details
print $channel->trace unless $channel->status;

DESCRIPTION

This module provides "email" method.

my $status = $channel->email( $data, $options );

The $data structure (hashref) describes body of message, the $options structure (hashref) describes parameters of the connection via external modules

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

EMail address of the recipient

from

EMail address of the sender

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

host

SMTP option "host". Contains hostname or IP of remote SMTP server

Default: localhost

port

SMTP option "port". Contains port to connect to

Defaults to 25 for non-SSL, 465 for 'ssl', 587 for 'starttls'

timeout

Maximum time in secs to wait for server

Default: 120

helo

SMTP attribute. What to say when saying HELO

No default

username

This is sasl_username SMTP attribute, is optional field.

Contains the username to use for auth

password

This is sasl_password SMTP attribute, the password to use for auth; required if username is provided

ssl

This is ssl SMTP attribute: if 'starttls', use STARTTLS; if 'ssl' (or 1), connect securely; otherwise, no security.

Default: undef

See Email::Sender::Transport::SMTP

ssl_options

This is ssl_options SMTP attribute (hashref): passed to Net::SMTP constructor for 'ssl' connections or to starttls for 'starttls' connections; should contain extra options for IO::Socket::SSL

Default: undef

See Email::Sender::Transport::SMTP

METHODS

init

For internal use only!

Called from base class. Returns initialize structure

handler

For internal use only!

Called from base class. Returns status of the operation

HISTORY

See CHANGES file

DEPENDENCIES

CTK, Email::MIME, Email::Sender

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

App::MonM::Notifier, Email::MIME, Email::Sender, Net::SMTP, IO::Socket::SSL, App::MonM::Notifier::Channel

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