NAME

Mailer - send electronic mail

SYNOPSIS

%status = Mailer::Send( %args );

DESCRIPTION

The Mailer.pm module contains one subroutine, Send, which takes a series of arguments and will send a copy of the e-mail message, with optional attachment, to everyone in the To:, CC:, and BCC: lists. Message, Subject, recipients, mail relay server, and From: can all be specified.

If a mail relay server is not specified, each recipient's address is deconstructed to get a mail server to send the message to. In this case, each copy of the message will be sent to the host, or domain name included in the recipient's address.

The Send subroutine will return a hash with each recipient's address as the key. For each recipient, the associated hash value is a string containing the status code and message resulting from the attempt to transmit that copy of the message. The status codes and messages are shown below.

METHODS

Send - send the message

%status = Mailer::Send( %args );

Arguments

@to           array of e-mail addresses of primary recipients for the message;
@cc           array of e-mail addresses of carbon copy recipients for the message;
@bcc          array of e-mail addresses of blind carbon copy recipients for the message;
$from         e-mail address that will be used as the From: address;
$mailserver   the name of the server through all e-mail will be injected;
$prefix       the Subject line prefix for the message;
$subject      the Subject: line for the message;
$message      a string containing the text body of the message;
$attachment   a string containing the filename of an attachment to be sent with the message;
$type         the type of the attachment,  this parameter will be guessed, if not specified;
$debug        reference to a file into which to capture debug output
$headers
@headers
%headers      a string, array, or hash of additional headers to send

Return codes

These codes and messages are returned in the value of the Mail Status hash:

 0  : OK
-1  : mailserver unknown
-2  : socket() failed
-3  : connect() failed
-4  : service not available
-5  : unspecified communication error
-6  : local user B<To:> unknown on host
-7  : transmission of message failed
-8  : argument B<To:> empty
-9  : no message specified
-10 : no file name specified
-11 : file not found
-12 : not available in singlepart mode
-13 : site specific error
-14 : connection not established
-15 : no SMTP server specified
-16 : no From: address specified
-17 : authentication protocol not accepted by the server
-18 : login not accepted
-19 : authentication protocol is not implemented
-20 : a mailer object could not be created

EXAMPLES

my %mailstatus = &Mailer::Send(
    to         => [foo@baz.com, bar@baz.com],
    cc         => [john@doe.org, jane@doe.org],
    bcc        => [bruce.wayne@batman.net],
    prefix     => "ATM",
    subject    => "Test Message",
    message    => 'This is a test message.',
    from       => 'me@from.com',
    mailserver => "mail.domain.com",
    attachment => "my-attachment.zip",
);

Copyright © 2000-2013 Applied Testing and Technology, Inc. All rights reserved.