Skip to content

iinteractive/Email-MIME-Kit-Bulk

Repository files navigation

NAME

Email::MIME::Kit::Bulk - Email::MIME::Kit-based bulk mailer

VERSION

version 0.0.3

SYNOPSIS

use Email::MIME::Kit::Bulk;
use Email::MIME::Kit::Bulk::Target;

my @targets = (
    Email::MIME::Kit::Bulk::Target->new(
        to => '[email protected]',
    ),
    Email::MIME::Kit::Bulk::Target->new(
        to => '[email protected]',
        cc => '[email protected]',
        language => 'en',
    ),
);

my $bulk = Email::MIME::Kit::Bulk->new(
    kit => '/path/to/mime/kit',
    processes => 5,
    targets => \@targets,
);

$bulk->send;

DESCRIPTION

Email::MIME::Kit::Bulk is an extension of Email::MIME::Kit for sending bulk emails. The module can be used directly, or via the companion script emk_bulk.

If a language is specified for a target, Email::MIME::Kit will use manifest._language_.json to generate its associated email. If no language is given, the regular manifest.json will be used instead.

If emk_bulk is used, it'll look in the kit directory for a targets.json file, which it'll use to create the email targets. The format of the targets.json file is a simple serialization of the Email::MIME::Kit::Bulk::Target constructor arguments:

[
{
    "to" : "[email protected]"
    "cc" : [
        "[email protected]"
    ],
    "language" : "en",
    "template_params" : {
        "superlative" : "Fantastic"
    },
},
{
    "to" : "[email protected]"
    "cc" : [
        "[email protected]"
    ],
    "language" : "fr",
    "template_params" : {
        "superlative" : "Extraordinaire"
    },
}
]

Email::MIME::Kit::Bulk uses MCE to parallize the sending of the emails. The number of processes used can be set via the processes constructor argument. By default MCE will select the number of processes based on the number of available processors. If the number of processes is set to be 1, MCE is bypassed altogether.

METHODS

new( %args )

Constructor.

Arguments

  • targets => \@targets

    Takes in an array of Email::MIME::Kit::Bulk::Target objects, which are the email would-be recipients.

    Either the argument targets or to must be passed to the constructor.

  • to => $email_address

    Email address of the 'To:' recipient. Ignored if targets is given as well.

  • cc => $email_address

    Email address of the 'Cc:' recipient. Ignored if targets is given as well.

  • bcc => $email_address

    Email address of the 'Bcc:' recipient. Ignored if targets is given as well.

  • kit => $path

    Path of the directory holding the files used by Email::MIME::Kit. Can be a string or a Path::Tiny object.

  • from => $email_address

    'From' address for the email .

  • processes => $nbr

    Maximal number of parallel processes used to send the emails.

    If not specified, will be chosen by MCE. If set to 1, the parallel processing will be skipped altogether.

    Not specified by default.

send()

Send the emails.

AUTHORS

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Infinity Interactive [email protected].

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

About

Email::MIME::Kit-based bulk mailer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages