Blame README

Packit b4291b
NAME
Packit b4291b
Packit b4291b
    Mail::Sender - (DEPRECATED) module for sending mails with attachments
Packit b4291b
    through an SMTP server
Packit b4291b
Packit b4291b
DEPRECATED
Packit b4291b
Packit b4291b
    Mail::Sender is deprecated. Email::Sender is the go-to choice when you
Packit b4291b
    need to send Email from Perl. Go there, be happy!
Packit b4291b
Packit b4291b
SYNOPSIS
Packit b4291b
Packit b4291b
      use Mail::Sender;
Packit b4291b
    
Packit b4291b
      my $sender = Mail::Sender->new({
Packit b4291b
        smtp => 'mail.yourdomain.com',
Packit b4291b
        from => 'your@address.com'
Packit b4291b
      });
Packit b4291b
      $sender->MailFile({
Packit b4291b
        to => 'some@address.com',
Packit b4291b
        subject => 'Here is the file',
Packit b4291b
        msg => "I'm sending you the list you wanted.",
Packit b4291b
        file => 'filename.txt'
Packit b4291b
      });
Packit b4291b
Packit b4291b
DESCRIPTION
Packit b4291b
Packit b4291b
    Mail::Sender is deprecated. Email::Sender is the go-to choice when you
Packit b4291b
    need to send Email from Perl. Go there, be happy!
Packit b4291b
Packit b4291b
    Mail::Sender provides an object-oriented interface to sending mails. It
Packit b4291b
    directly connects to the mail server using IO::Socket.
Packit b4291b
Packit b4291b
ATTRIBUTES
Packit b4291b
Packit b4291b
    Mail::Sender implements the following attributes.
Packit b4291b
Packit b4291b
    * Please note that altering an attribute after object creation is best
Packit b4291b
    handled with creating a copy using $sender = $sender->new({attribute =>
Packit b4291b
    'value'}). To obtain the current value of an attribute, break all the
Packit b4291b
    rules and reach in there! my $val = $sender->{attribute};
Packit b4291b
Packit b4291b
 auth
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({auth => 'PLAIN'});
Packit b4291b
        my $auth = $sender->{auth}; # reach in to grab
Packit b4291b
Packit b4291b
    The SMTP authentication protocol to use to login to the server
Packit b4291b
    currently the only ones supported are LOGIN, PLAIN, CRAM-MD5 and NTLM.
Packit b4291b
    Some protocols have module dependencies. CRAM-MD5 depends on
Packit b4291b
    Digest::HMAC_MD5 and NTLM on Authen::NTLM.
Packit b4291b
Packit b4291b
    You may add support for other authentication protocols yourself.
Packit b4291b
Packit b4291b
 auth_encoded
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({auth_encoded => 1});
Packit b4291b
        my $auth_enc = $sender->{auth_encoded}; # reach in to grab
Packit b4291b
Packit b4291b
    If set to a true value, Mail::Sender attempts to use TLS (encrypted
Packit b4291b
    connection) whenever the server supports it and you have
Packit b4291b
    IO::Socket::SSL and Net::SSLeay.
Packit b4291b
Packit b4291b
    The default value of this option is true! This means that if
Packit b4291b
    Mail::Sender can send the data encrypted, it will.
Packit b4291b
Packit b4291b
 authdomain
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({authdomain => 'bar.com'});
Packit b4291b
        my $domain = $sender->{authdomain}; # reach in to grab
Packit b4291b
Packit b4291b
    The domain name; used optionally by the NTLM authentication. Other
Packit b4291b
    authentication protocols may use other options as well. They should all
Packit b4291b
    start with auth though.
Packit b4291b
Packit b4291b
 authid
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({authid => 'username'});
Packit b4291b
        my $username = $sender->{authid}; # reach in to grab
Packit b4291b
Packit b4291b
    The username used to login to the server.
Packit b4291b
Packit b4291b
 authpwd
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({authpwd => 'password'});
Packit b4291b
        my $password = $sender->{authpwd}; # reach in to grab
Packit b4291b
Packit b4291b
    The password used to login to the server.
Packit b4291b
Packit b4291b
 bcc
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({bcc => 'foo@bar.com'});
Packit b4291b
        $sender = $sender->new({bcc => 'foo@bar.com, bar@baz.com'});
Packit b4291b
        $sender = $sender->new({bcc => ['foo@bar.com', 'bar@baz.com']});
Packit b4291b
        my $bcc = $sender->{bcc}; # reach in to grab
Packit b4291b
Packit b4291b
    Send a blind carbon copy to these addresses.
Packit b4291b
Packit b4291b
 boundary
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({boundary => '--'});
Packit b4291b
        my $boundary = $sender->{boundary}; # reach in to grab
Packit b4291b
Packit b4291b
    The message boundary. You usually do not have to change this, it might
Packit b4291b
    only come in handy if you need to attach a multi-part mail created by
Packit b4291b
    Mail::Sender to your message as a single part. Even in that case any
Packit b4291b
    problems are unlikely.
Packit b4291b
Packit b4291b
 cc
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({cc => 'foo@bar.com'});
Packit b4291b
        $sender = $sender->new({cc => 'foo@bar.com, bar@baz.com'});
Packit b4291b
        $sender = $sender->new({cc => ['foo@bar.com', 'bar@baz.com']});
Packit b4291b
        my $cc = $sender->{cc}; # reach in to grab
Packit b4291b
Packit b4291b
    Send a carbon copy to these addresses.
Packit b4291b
Packit b4291b
 charset
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({charset => 'UTF-8'});
Packit b4291b
        my $charset = $sender->{charset}; # reach in to grab
Packit b4291b
Packit b4291b
    The charset of the single part message or the body of the multi-part
Packit b4291b
    one.
Packit b4291b
Packit b4291b
 client
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({client => 'localhost.localdomain'});
Packit b4291b
        my $client = $sender->{client}; # reach in to grab
Packit b4291b
Packit b4291b
    The name of the client computer.
Packit b4291b
Packit b4291b
    During the connection you send the mail server your computer's name. By
Packit b4291b
    default Mail::Sender sends (gethostbyname 'localhost')[0]. If that is
Packit b4291b
    not the address your needs, you can specify a different one.
Packit b4291b
Packit b4291b
 confirm
Packit b4291b
Packit b4291b
        # only delivery, to the 'from' address
Packit b4291b
        $sender = $sender->new({confirm => 'delivery'});
Packit b4291b
        # only reading, to the 'from' address
Packit b4291b
        $sender = $sender->new({confirm => 'reading'});
Packit b4291b
        # both: to the 'from' address
Packit b4291b
        $sender = $sender->new({confirm => 'delivery, reading'});
Packit b4291b
        # delivery: to specified address
Packit b4291b
        $sender = $sender->new({confirm => 'delivery: my.other@address.com'});
Packit b4291b
        my $confirm = $sender->{confirm}; # reach in to grab
Packit b4291b
Packit b4291b
    Whether you want to request reading or delivery confirmations and to
Packit b4291b
    what addresses.
Packit b4291b
Packit b4291b
    Keep in mind that confirmations are not guaranteed to work. Some
Packit b4291b
    servers/mail clients do not support this feature and some users/admins
Packit b4291b
    may have disabled it. So it's possible that your mail was delivered and
Packit b4291b
    read, but you won't get any confirmation!
Packit b4291b
Packit b4291b
 createmessageid
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({createmessageid => sub {
Packit b4291b
            my $from = shift;
Packit b4291b
            my ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time);
Packit b4291b
            $mon++;
Packit b4291b
            $year += 1900;
Packit b4291b
    
Packit b4291b
            return sprintf "<%04d%02d%02d_%02d%02d%02d_%06d.%s>", $year, $mon, $mday,
Packit b4291b
                $hour, $min, $sec, rand(100000), $from;
Packit b4291b
        }});
Packit b4291b
        my $cm_id = $sender->{createmessageid}; # reach in to grab
Packit b4291b
Packit b4291b
    This option allows you to overwrite the function that generates the
Packit b4291b
    message IDs for the emails. The option gets the "pure" sender's address
Packit b4291b
    as it's only parameter and is supposed to return a string. See the
Packit b4291b
    "MessageID" in Mail::Sender method.
Packit b4291b
Packit b4291b
    If you want to specify a message id you can also use the messageid
Packit b4291b
    parameter for the "Open" in Mail::Sender, "OpenMultipart" in
Packit b4291b
    Mail::Sender, "MailMsg" in Mail::Sender or "MailFile" in Mail::Sender
Packit b4291b
    methods.
Packit b4291b
Packit b4291b
 ctype
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({ctype => 'text/plain'});
Packit b4291b
        my $type = $sender->{ctype}; # reach in to grab
Packit b4291b
Packit b4291b
    The content type of a single part message or the body of the multi-part
Packit b4291b
    one.
Packit b4291b
Packit b4291b
    Please do not confuse these two. The "multipart" in Mail::Sender
Packit b4291b
    parameter is used to specify the overall content type of a multi-part
Packit b4291b
    message (for example any HTML document with inlined images) while ctype
Packit b4291b
    is an ordinary content type for a single part message or the body of a
Packit b4291b
    multi-part message.
Packit b4291b
Packit b4291b
 debug
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({debug => '/path/to/debug/file.txt'});
Packit b4291b
        $sender = $sender->new({debug => $file_handle});
Packit b4291b
        my $debug = $sender->{debug}; # reach in to grab
Packit b4291b
Packit b4291b
    All the conversation with the server will be logged to that file or
Packit b4291b
    handle. All lines in the file should end with CRLF (the Windows and
Packit b4291b
    Internet format).
Packit b4291b
Packit b4291b
    If you pass the path to the log file, Mail::Sender will overwrite it.
Packit b4291b
    If you want to append to the file, you have to open it yourself and
Packit b4291b
    pass the filehandle:
Packit b4291b
Packit b4291b
        open my $fh, '>>', '/path/to/file.txt' or die "Can't open: $!";
Packit b4291b
        my $sender = Mail::Sender->new({
Packit b4291b
            debug => $fh,
Packit b4291b
        });
Packit b4291b
Packit b4291b
 debug_level
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({debug_level => 1});
Packit b4291b
        # 1: only log server communication, skip all msg data
Packit b4291b
        # 2: log server comm. and message headers
Packit b4291b
        # 3: log server comm., message and part headers
Packit b4291b
        # 4: log everything (default behavior)
Packit b4291b
        my $level = $sender->{debug_level}; # reach in to grab
Packit b4291b
Packit b4291b
    Only taken into account if the debug attribute is specified.
Packit b4291b
Packit b4291b
 encoding
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({encoding => 'Quoted-printable'});
Packit b4291b
        my $encoding = $sender->{encoding}; # reach in to grab
Packit b4291b
Packit b4291b
    Encoding of a single part message or the body of a multi-part message.
Packit b4291b
Packit b4291b
    If the text of the message contains some extended characters or very
Packit b4291b
    long lines, you should use encoding => 'Quoted-printable' in the call
Packit b4291b
    to "Open" in Mail::Sender, "OpenMultipart" in Mail::Sender, "MailMsg"
Packit b4291b
    in Mail::Sender or "MailFile" in Mail::Sender.
Packit b4291b
Packit b4291b
    If you use some encoding you should either use "SendEnc" in
Packit b4291b
    Mail::Sender or encode the data yourself!
Packit b4291b
Packit b4291b
 ESMPT
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({
Packit b4291b
            ESMTP => {
Packit b4291b
                NOTIFY => 'SUCCESS,FAILURE,DELAY',
Packit b4291b
                RET => 'HDRS',
Packit b4291b
                ORCPT => 'rfc822;my.other@address.com',
Packit b4291b
                ENVID => 'iuhsdfobwoe8t237',
Packit b4291b
            },
Packit b4291b
        });
Packit b4291b
        my $esmtp = $sender->{ESMTP}; # reach in to grab
Packit b4291b
Packit b4291b
    This option contains data for SMTP extensions. For example, it allows
Packit b4291b
    you to request delivery status notifications according to RFC1891
Packit b4291b
    <https://tools.ietf.org/html/rfc1891>. If the SMTP server you connect
Packit b4291b
    to doesn't support this extension, the options will be ignored. You do
Packit b4291b
    not need to worry about encoding the ORCPT or ENVID parameters.
Packit b4291b
Packit b4291b
      * ENVID - Used to propagate an identifier for this message
Packit b4291b
      transmission envelope, which is also known to the sender and will, if
Packit b4291b
      present, be returned in any Delivery Status Notifications issued for
Packit b4291b
      this transmission.
Packit b4291b
Packit b4291b
      * NOTIFY - To specify the conditions under which a delivery status
Packit b4291b
      notification should be generated. Should be either NEVER or a
Packit b4291b
      comma-separated list of SUCCESS, FAILURE and DELAY.
Packit b4291b
Packit b4291b
      * ORCPT - Used to convey the original (sender-specified) recipient
Packit b4291b
      address.
Packit b4291b
Packit b4291b
      * RET - To request that Delivery Status Notifications containing an
Packit b4291b
      indication of delivery failure either return the entire contents of a
Packit b4291b
      message or only the message headers. Must be either FULL or HDRS.
Packit b4291b
Packit b4291b
 fake_cc
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({fake_cc => 'foo@bar.com'});
Packit b4291b
        my $fake_cc = $sender->{fake_cc}; # reach in to grab
Packit b4291b
Packit b4291b
    The address that will be shown in headers. If not specified, the "cc"
Packit b4291b
    in Mail::Sender attribute will be used.
Packit b4291b
Packit b4291b
 fake_from
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({fake_from => 'foo@bar.com'});
Packit b4291b
        my $fake_from = $sender->{fake_from}; # reach in to grab
Packit b4291b
Packit b4291b
    The address that will be shown in headers. If not specified, the "from"
Packit b4291b
    in Mail::Sender attribute will be used.
Packit b4291b
Packit b4291b
 fake_to
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({fake_to => 'foo@bar.com'});
Packit b4291b
        my $fake_to = $sender->{fake_to}; # reach in to grab
Packit b4291b
Packit b4291b
    The recipient's address that will be shown in headers. If not
Packit b4291b
    specified, the "to" in Mail::Sender attribute will be used.
Packit b4291b
Packit b4291b
    If the list of addresses you want to send your message to is long or if
Packit b4291b
    you do not want the recipients to see each other's address set the
Packit b4291b
    "fake_to" in Mail::Sender parameter to some informative, yet bogus,
Packit b4291b
    address or to the address of your mailing/distribution list.
Packit b4291b
Packit b4291b
 from
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({from => 'foo@bar.com'});
Packit b4291b
        my $from = $sender->{from}; # reach in to grab
Packit b4291b
Packit b4291b
    The sender's email address.
Packit b4291b
Packit b4291b
 headers
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({headers => 'Content-Type: text/plain'});
Packit b4291b
        $sender = $sender->new({headers => {'Content-Type' => 'text/plain'}});
Packit b4291b
        my $headers = $sender->{headers}; # reach in to grab
Packit b4291b
Packit b4291b
    You may use this parameter to add custom headers into the message. The
Packit b4291b
    parameter may be either a string containing the headers in the right
Packit b4291b
    format or a hash containing the headers and their values.
Packit b4291b
Packit b4291b
 keepconnection
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({keepconnection => 1);
Packit b4291b
        $sender = $sender->new({keepconnection => 0});
Packit b4291b
        my $keepcon = $sender->{keepconnection}; # reach in to grab
Packit b4291b
Packit b4291b
    If set to a true value, it causes the Mail::Sender to keep the
Packit b4291b
    connection open for several messages. The connection will be closed if
Packit b4291b
    you call the "Close" in Mail::Sender method with a true value or if you
Packit b4291b
    call "Open" in Mail::Sender, "OpenMultipart" in Mail::Sender, "MailMsg"
Packit b4291b
    in Mail::Sender or "MailFile" in Mail::Sender with the smtp attribute.
Packit b4291b
    This means that if you want the object to keep the connection, you
Packit b4291b
    should pass the smtp either to "new" in Mail::Sender or only to the
Packit b4291b
    first "Open" in Mail::Sender, "OpenMultipart" in Mail::Sender,
Packit b4291b
    "MailMsg" in Mail::Sender or "MailFile" in Mail::Sender!
Packit b4291b
Packit b4291b
 multipart
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({multipart => 'Mixed'});
Packit b4291b
        my $multi = $sender->{multipart}; # reach in to grab
Packit b4291b
Packit b4291b
    The MIME subtype for the whole message (Mixed/Related/Alternative). You
Packit b4291b
    may need to change this setting if you want to send an HTML body with
Packit b4291b
    some inline images, or if you want to post the message in plain text as
Packit b4291b
    well as HTML (alternative).
Packit b4291b
Packit b4291b
 on_errors
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({on_errors => 'undef'}); # return undef on error
Packit b4291b
        $sender = $sender->new({on_errors => 'die'}); # raise an exception
Packit b4291b
        $sender = $sender->new({on_errors => 'code'}); # return the negative error code (default)
Packit b4291b
        # -1 = $smtphost unknown
Packit b4291b
        # -2 = socket() failed
Packit b4291b
        # -3 = connect() failed
Packit b4291b
        # -4 = service not available
Packit b4291b
        # -5 = unspecified communication error
Packit b4291b
        # -6 = local user $to unknown on host $smtp
Packit b4291b
        # -7 = transmission of message failed
Packit b4291b
        # -8 = argument $to empty
Packit b4291b
        # -9 = no message specified in call to MailMsg or MailFile
Packit b4291b
        # -10 = no file name specified in call to SendFile or MailFile
Packit b4291b
        # -11 = file not found
Packit b4291b
        # -12 = not available in singlepart mode
Packit b4291b
        # -13 = site specific error
Packit b4291b
        # -14 = connection not established. Did you mean MailFile instead of SendFile?
Packit b4291b
        # -15 = no SMTP server specified
Packit b4291b
        # -16 = no From: address specified
Packit b4291b
        # -17 = authentication protocol not accepted by the server
Packit b4291b
        # -18 = login not accepted
Packit b4291b
        # -19 = authentication protocol is not implemented
Packit b4291b
        # -20 = all recipients were rejected by the server
Packit b4291b
        # -21 = file specified as an attachment cannot be read
Packit b4291b
        # -22 = failed to open the specified debug file for writing
Packit b4291b
        # -23 = STARTTLS failed (for SSL or TLS encrypted connections)
Packit b4291b
        # -24 = IO::Socket::SSL->start_SSL failed
Packit b4291b
        # -25 = TLS required by the specified options, but the required modules are not available. Need IO::Socket::SSL and Net::SSLeay
Packit b4291b
        # -26 = TLS required by the specified options, but the server doesn't support it
Packit b4291b
        # -27 = unknown encoding specified for the mail body, part or attachment. Only base64, quoted-printable, 7bit and 8bit supported.
Packit b4291b
        my $on_errors = $sender->{on_errors}; # reach in to grab
Packit b4291b
        say $Mail::Sender::Error; # contains a textual description of last error.
Packit b4291b
Packit b4291b
    This option allows you to affect the way Mail::Sender reports errors.
Packit b4291b
    All methods return the $sender object if they succeed.
Packit b4291b
Packit b4291b
    $Mail::Sender::Error $sender->{'error'} and $sender->{'error_msg'} are
Packit b4291b
    set in all cases.
Packit b4291b
Packit b4291b
 port
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({port => 25});
Packit b4291b
        my $port = $sender->{port}; # reach in to grab
Packit b4291b
Packit b4291b
    The TCP/IP port used form the connection. By default
Packit b4291b
    getservbyname('smtp', 'tcp')||25. You should only need to use this
Packit b4291b
    option if your mail server waits on a nonstandard port.
Packit b4291b
Packit b4291b
 priority
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({priority => 1});
Packit b4291b
        # 1. highest
Packit b4291b
        # 2. high
Packit b4291b
        # 3. normal
Packit b4291b
        # 4. low
Packit b4291b
        # 5. lowest
Packit b4291b
        my $priority = $sender->{priority}; # reach in to grab
Packit b4291b
Packit b4291b
    The message priority number.
Packit b4291b
Packit b4291b
 replyto
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({replyto => 'foo@bar.com'});
Packit b4291b
        my $replyto = $sender->{replyto}; # reach in to grab
Packit b4291b
Packit b4291b
    The reply to address.
Packit b4291b
Packit b4291b
 skip_bad_recipients
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({skip_bad_recipients => 1);
Packit b4291b
        $sender = $sender->new({skip_bad_recipients => 0});
Packit b4291b
        my $skip = $sender->{skip_bad_recipients}; # reach in to grab
Packit b4291b
Packit b4291b
    If this option is set to false, or not specified, then Mail::Sender
Packit b4291b
    stops trying to send a message as soon as the first recipient's address
Packit b4291b
    fails. If it is set to a true value, Mail::Sender skips the bad
Packit b4291b
    addresses and tries to send the message at least to the good ones. If
Packit b4291b
    all addresses are rejected by the server, it reports a All recipients
Packit b4291b
    were rejected message.
Packit b4291b
Packit b4291b
    If any addresses were skipped, the $sender->{'skipped_recipients'} will
Packit b4291b
    be a reference to a hash containing the failed address and the server's
Packit b4291b
    response.
Packit b4291b
Packit b4291b
 smtp
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({smtp => 'smtp.bar.com'});
Packit b4291b
        my $smtp = $sender->{smtp}; # reach in to grab
Packit b4291b
Packit b4291b
    The IP address or domain of your SMTP server.
Packit b4291b
Packit b4291b
 ssl_...
Packit b4291b
Packit b4291b
    The ssl_version, ssl_verify_mode, ssl_ca_path, ssl_ca_file,
Packit b4291b
    ssl_verifycb_name, ssl_verifycn_schema and ssl_hostname options (if
Packit b4291b
    specified) are passed to "start_SSL" in IO::Socket::SSL. The default
Packit b4291b
    version is TLSv1 and verify mode is IO::Socket::SSL::SSL_VERIFY_NONE.
Packit b4291b
Packit b4291b
    If you change the ssl_verify_mode to SSL_VERIFY_PEER, you may need to
Packit b4291b
    specify the ssl_ca_file. If you have Mozilla::CA installed, then
Packit b4291b
    setting it to Mozilla::CA::SSL_ca_file() may help.
Packit b4291b
Packit b4291b
 subject
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({subject => 'An email is coming!'});
Packit b4291b
        my $subject = $sender->{subject}; # reach in to grab
Packit b4291b
Packit b4291b
    The subject of the message.
Packit b4291b
Packit b4291b
 tls_allowed
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({tls_allowed => 1}); # true, default
Packit b4291b
        $sender = $sender->new({tls_allowed => 0}); # false
Packit b4291b
        my $tls = $sender->{tls_allowed}; # reach in to grab
Packit b4291b
Packit b4291b
    If set to a true value, Mail::Sender will attempt to use TLS (encrypted
Packit b4291b
    connection) whenever the server supports it. This requires that you
Packit b4291b
    have IO::Socket::SSL and Net::SSLeay.
Packit b4291b
Packit b4291b
 tls_required
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({tls_required => 1}); # true, require TLS encryption
Packit b4291b
        $sender = $sender->new({tls_required => 0}); # false, plain. default
Packit b4291b
        my $required = $sender->{tls_required};
Packit b4291b
Packit b4291b
    If you set this option to a true value, the module will fail if it's
Packit b4291b
    unable to use TLS.
Packit b4291b
Packit b4291b
 to
Packit b4291b
Packit b4291b
        # mutating single attributes could get costly!
Packit b4291b
        $sender = $sender->new({to => 'foo@bar.com'});
Packit b4291b
        $sender = $sender->new({to => 'foo@bar.com, bar@baz.com'});
Packit b4291b
        $sender = $sender->new({to => ['foo@bar.com', 'bar@baz.com']});
Packit b4291b
        my $to = $sender->{to}; # reach in to grab
Packit b4291b
Packit b4291b
    The recipient's addresses. This parameter may be either a comma
Packit b4291b
    separated list of email addresses or a reference to a list of
Packit b4291b
    addresses.
Packit b4291b
Packit b4291b
METHODS
Packit b4291b
Packit b4291b
    Mail::Sender implements the following methods.
Packit b4291b
Packit b4291b
 Attach
Packit b4291b
Packit b4291b
        # set parameters in an ordered list
Packit b4291b
        # -- description, ctype, encoding, disposition, file(s)
Packit b4291b
        $sender = $sender->Attach(
Packit b4291b
            'title', 'application/octet-stream', 'Base64', 'attachment; filename=*', '/file.txt'
Packit b4291b
        );
Packit b4291b
        $sender = $sender->Attach(
Packit b4291b
            'title', 'application/octet-stream', 'Base64', 'attachment; filename=*',
Packit b4291b
            ['/file.txt', '/file2.txt']
Packit b4291b
        );
Packit b4291b
        # OR use a hashref
Packit b4291b
        $sender = $sender->Attach({
Packit b4291b
            description => 'some title',
Packit b4291b
            charset => 'US-ASCII', # default
Packit b4291b
            encoding => 'Base64', # default
Packit b4291b
            ctype => 'application/octet-stream', # default
Packit b4291b
            disposition => 'attachment; filename=*', # default
Packit b4291b
            file => ['/file1.txt'], # file names
Packit b4291b
            content_id => '#', # for auto-increment number, or * for filename
Packit b4291b
        });
Packit b4291b
Packit b4291b
    Sends a file as a separate part of the mail message. Only in multi-part
Packit b4291b
    mode.
Packit b4291b
Packit b4291b
 Body
Packit b4291b
Packit b4291b
        # set parameters in an ordered list
Packit b4291b
        # -- charset, encoding, content-type
Packit b4291b
        $sender = $sender->Body('US-ASCII', '7BIT', 'text/plain');
Packit b4291b
        # OR use a hashref
Packit b4291b
        $sender = $sender->Body({
Packit b4291b
            charset => 'US-ASCII', # default
Packit b4291b
            encoding => '7BIT', # default
Packit b4291b
            ctype => 'text/plain', # default
Packit b4291b
            msg => '',
Packit b4291b
        });
Packit b4291b
Packit b4291b
    Sends the head of the multi-part message body. You can specify the
Packit b4291b
    charset and the encoding.
Packit b4291b
Packit b4291b
 Cancel
Packit b4291b
Packit b4291b
        $sender = $sender->Cancel;
Packit b4291b
Packit b4291b
    Cancel an opened message.
Packit b4291b
Packit b4291b
    "SendFile" in Mail::Sender and other methods may set
Packit b4291b
    $sender->{'error'}. In that case "undef $sender" calls $sender->Cancel
Packit b4291b
    not $sender->Close!!!
Packit b4291b
Packit b4291b
 ClearErrors
Packit b4291b
Packit b4291b
        $sender->ClearErrors();
Packit b4291b
Packit b4291b
    Make the various error variables undef.
Packit b4291b
Packit b4291b
 Close
Packit b4291b
Packit b4291b
        $sender->Close();
Packit b4291b
        $sender->Close(1); # force override keepconnection
Packit b4291b
Packit b4291b
    Close and send the email message. If you pass a true value to the
Packit b4291b
    method the connection will be closed even if the keepconnection was
Packit b4291b
    specified. You should only keep the connection open if you plan to send
Packit b4291b
    another message immediately. And you should not keep it open for
Packit b4291b
    hundreds of emails even if you do send them all in a row.
Packit b4291b
Packit b4291b
    This method should be called automatically when destructing the object,
Packit b4291b
    but you should not rely on it. If you want to be sure your message WAS
Packit b4291b
    processed by the server, you SHOULD call "Close" in Mail::Sender
Packit b4291b
    explicitly.
Packit b4291b
Packit b4291b
 Connect
Packit b4291b
Packit b4291b
    This method gets called automatically. Do not call it yourself.
Packit b4291b
Packit b4291b
 Connected
Packit b4291b
Packit b4291b
        my $bool = $sender->Connected();
Packit b4291b
Packit b4291b
    Returns an undef or true value to let you know if you're connected to
Packit b4291b
    the mail server.
Packit b4291b
Packit b4291b
 EndPart
Packit b4291b
Packit b4291b
        $sender = $sender->EndPart($ctype);
Packit b4291b
Packit b4291b
    Closes a multi-part part.
Packit b4291b
Packit b4291b
    If the $ctype is not present or evaluates to false, only the current
Packit b4291b
    SIMPLE part is closed! Don't do that unless you are really sure you
Packit b4291b
    know what you are doing.
Packit b4291b
Packit b4291b
    It's best to always pass to the ->EndPart() the content type of the
Packit b4291b
    corresponding ->Part().
Packit b4291b
Packit b4291b
 GetHandle
Packit b4291b
Packit b4291b
        $sender->Open({...});
Packit b4291b
        my $handle = $sender->GetHandle();
Packit b4291b
        $handle->print("Hello world.\n");
Packit b4291b
        my ($mday,$mon,$year) = (localtime())[3,4,5];
Packit b4291b
        $handle->print(sprintf("Today is %04d/%02d/%02d.", $year+1900, $mon+1, $mday));
Packit b4291b
        close $handle;
Packit b4291b
Packit b4291b
    Returns a file handle to which you can print the message or file to
Packit b4291b
    attach. The data you print to this handle will be encoded as necessary.
Packit b4291b
    Closing this handle closes either the message (for single part
Packit b4291b
    messages) or the part.
Packit b4291b
Packit b4291b
 MailFile
Packit b4291b
Packit b4291b
        # set parameters in an ordered list
Packit b4291b
        # -- from, reply-to, to, smtp, subject, headers, message, files(s)
Packit b4291b
        $sender = $sender->MailFile('from@foo.com','reply-to@bar.com','to@baz.com')
Packit b4291b
        # OR use a hashref -- see the attributes section for a
Packit b4291b
        # list of appropriate parameters.
Packit b4291b
        $sender = $sender->MailFile({file => ['/file1','/file2'], msg => "Message"});
Packit b4291b
Packit b4291b
    Sends one or more files by mail. If a message in $sender is opened, it
Packit b4291b
    gets closed and a new message is created and sent. $sender is then
Packit b4291b
    closed.
Packit b4291b
Packit b4291b
    The file parameter may be a string file name, a comma-separated list of
Packit b4291b
    filenames, or an array reference of filenames.
Packit b4291b
Packit b4291b
    Keep in mind that parameters like ctype, charset and encoding will be
Packit b4291b
    used for the attached file, not the body of the message. If you want to
Packit b4291b
    specify those parameters for the body, you have to use b_ctype,
Packit b4291b
    b_charset and b_encoding.
Packit b4291b
Packit b4291b
 MailMsg
Packit b4291b
Packit b4291b
        # set parameters in an ordered list
Packit b4291b
        # -- from, reply-to, to, smtp, subject, headers, message
Packit b4291b
        $sender = $sender->MailMsg('from@foo.com','reply-to@bar.com','to@baz.com')
Packit b4291b
        # OR use a hashref -- see the attributes section for a
Packit b4291b
        # list of appropriate parameters.
Packit b4291b
        $sender = $sender->MailMsg({from => "foo@bar.com", msg => "Message"});
Packit b4291b
Packit b4291b
    Sends a message. If a message in $sender is opened, it gets closed and
Packit b4291b
    a new message is created and sent. $sender is then closed.
Packit b4291b
Packit b4291b
 new
Packit b4291b
Packit b4291b
        # Create a new sender instance with only the 'from' address
Packit b4291b
        my $sender = Mail::Sender->new('from_address@bar.com');
Packit b4291b
        # Create a new sender with any attribute above set in a hashref
Packit b4291b
        my $sender = Mail::Sender->new({attribute => 'value', });
Packit b4291b
        # Create a new sender as a copy of an existing one
Packit b4291b
        my $copy = $sender->new({another_attr => 'bar',});
Packit b4291b
Packit b4291b
    Prepares a sender. Any attribute can be set during instance creation.
Packit b4291b
    This doesn't start any connection to the server. You have to use
Packit b4291b
    $sender->Open or $sender->OpenMultipart to start talking to the server.
Packit b4291b
Packit b4291b
    The attributes are used in subsequent calls to $sender->Open and
Packit b4291b
    $sender->OpenMultipart. Each such call changes the saved variables. You
Packit b4291b
    can set smtp, from and other options here and then use the info in all
Packit b4291b
    messages.
Packit b4291b
Packit b4291b
 Open
Packit b4291b
Packit b4291b
        # set parameters in an ordered list
Packit b4291b
        # -- from, reply-to, to, smtp, subject, headers
Packit b4291b
        $sender = $sender->Open('from@foo.com','reply-to@bar.com','to@baz.com');
Packit b4291b
        # OR use a hashref -- see the attributes section for a
Packit b4291b
        # list of appropriate parameters.
Packit b4291b
        $sender = $sender->Open({to=>'to@baz.com', subject=>'Incoming!!!'});
Packit b4291b
Packit b4291b
    Opens a new message. The only additional parameter that may not be
Packit b4291b
    specified directly in "new" in Mail::Sender is messageid. If you set
Packit b4291b
    this option, the message will be sent with that Message-ID, otherwise a
Packit b4291b
    new Message ID will be generated out of the sender's address, current
Packit b4291b
    date+time and a random number (or by the function you specified in the
Packit b4291b
    createmessageid attribute).
Packit b4291b
Packit b4291b
    After the message is sent $sender->{messageid} will contain the
Packit b4291b
    Message-ID with which the message was sent.
Packit b4291b
Packit b4291b
 OpenMultipart
Packit b4291b
Packit b4291b
        # set parameters in an ordered list
Packit b4291b
        # -- from, reply-to, to, smtp, subject, headers, boundary
Packit b4291b
        $sender = $sender->OpenMultipart('from@foo.com','reply-to@bar.com');
Packit b4291b
        # OR use a hashref -- see the attributes section for a
Packit b4291b
        # list of appropriate parameters.
Packit b4291b
        $sender = $sender->OpenMultipart({to=>'to@baz.com', subject=>'Incoming!!!'});
Packit b4291b
Packit b4291b
    Opens a multipart message.
Packit b4291b
Packit b4291b
 Part
Packit b4291b
Packit b4291b
        # set parameters in an ordered list
Packit b4291b
        # -- description, ctype, encoding, disposition, content_id, Message
Packit b4291b
        $sender = $sender->Part(
Packit b4291b
            'something', 'text/plain', '7BIT', 'attachment; filename="send.pl"'
Packit b4291b
        );
Packit b4291b
        # OR use a hashref -- see the attributes section for a
Packit b4291b
        # list of appropriate parameters.
Packit b4291b
        $sender = $sender->Part({
Packit b4291b
            description => "desc",
Packit b4291b
            ctype => "application/octet-stream", # default
Packit b4291b
            encoding => '7BIT', # default
Packit b4291b
            disposition => 'attachment', # default
Packit b4291b
            content_id => '#', # for auto-increment number, or * for filename
Packit b4291b
            msg => '', # You don't have to specify here, you may use SendEnc()
Packit b4291b
                        # to add content to the part.
Packit b4291b
        });
Packit b4291b
Packit b4291b
    Prints a part header for the multipart message and (if specified) the
Packit b4291b
    contents.
Packit b4291b
Packit b4291b
 print
Packit b4291b
Packit b4291b
    An alias for "SendEnc" in Mail::Sender.
Packit b4291b
Packit b4291b
 QueryAuthProtocols
Packit b4291b
Packit b4291b
        my @protocols = $sender->QueryAuthProtocols();
Packit b4291b
        my @protocols = $sender->QueryAuthProtocols( $smtpserver);
Packit b4291b
Packit b4291b
    Queries the server specified in the attributes or in the parameter to
Packit b4291b
    this method for the authentication protocols it supports.
Packit b4291b
Packit b4291b
 Send
Packit b4291b
Packit b4291b
        $sender = $sender->Send(@strings);
Packit b4291b
Packit b4291b
    Prints the strings to the socket. It doesn't add any line terminations
Packit b4291b
    or encoding. You should use \r\n as the end-of-line!
Packit b4291b
Packit b4291b
    UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
Packit b4291b
    USE "SendEnc" in Mail::Sender INSTEAD!
Packit b4291b
Packit b4291b
 SendEnc
Packit b4291b
Packit b4291b
        $sender = $sender->SendEnc(@strings);
Packit b4291b
Packit b4291b
    Prints the bytes to the socket. It doesn't add any line terminations.
Packit b4291b
    Encodes the text using the selected encoding: none | Base64 |
Packit b4291b
    Quoted-printable. You should use \r\n as the end-of-line!
Packit b4291b
Packit b4291b
 SendEx
Packit b4291b
Packit b4291b
        $sender = $sender->SendEx(@strings);
Packit b4291b
Packit b4291b
    Prints the strings to the socket. Doesn't add any end-of-line
Packit b4291b
    characters. Changes all end-of-lines to \r\n. Doesn't encode the data!
Packit b4291b
Packit b4291b
    UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
Packit b4291b
    USE "SendEnc" in Mail::Sender INSTEAD!
Packit b4291b
Packit b4291b
 SendFile
Packit b4291b
Packit b4291b
    Alias for "Attach" in Mail::Sender
Packit b4291b
Packit b4291b
 SendLine
Packit b4291b
Packit b4291b
        $sender = $sender->SendLine(@strings);
Packit b4291b
Packit b4291b
    Prints the strings to the socket. Each byte string is terminated by
Packit b4291b
    \r\n. No encoding is done. You should use \r\n as the end-of-line!
Packit b4291b
Packit b4291b
    UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
Packit b4291b
    USE "SendLineEnc" in Mail::Sender INSTEAD!
Packit b4291b
Packit b4291b
 SendLineEnc
Packit b4291b
Packit b4291b
        $sender = $sender->SendLineEnc(@strings);
Packit b4291b
Packit b4291b
    Prints the strings to the socket and adds the end-of-line character at
Packit b4291b
    the end. Encodes the text using the selected encoding: none | Base64 |
Packit b4291b
    Quoted-printable.
Packit b4291b
Packit b4291b
    Do NOT mix up "Send" in Mail::Sender, "SendEx" in Mail::Sender,
Packit b4291b
    "SendLine" in Mail::Sender, or "SendLineEx" in Mail::Sender with
Packit b4291b
    "SendEnc" in Mail::Sender or "SendLineEnc" in Mail::Sender! "SendEnc"
Packit b4291b
    in Mail::Sender does some buffering necessary for correct Base64
Packit b4291b
    encoding, and "Send" in Mail::Sender and "SendEx" in Mail::Sender are
Packit b4291b
    not aware of that.
Packit b4291b
Packit b4291b
    Usage of "Send" in Mail::Sender, "SendEx" in Mail::Sender, "SendLine"
Packit b4291b
    in Mail::Sender, and "SendLineEx" in Mail::Sender in non xBIT parts is
Packit b4291b
    not recommended. Using Send(encode_base64($string)) may work, but more
Packit b4291b
    likely it will not! In particular, if you use several such to create
Packit b4291b
    one part, the data is very likely to get crippled.
Packit b4291b
Packit b4291b
 SendLineEx
Packit b4291b
Packit b4291b
        $sender = $sender->SendLineEnc(@strings);
Packit b4291b
Packit b4291b
    Prints the strings to the socket. Adds an end-of-line character at the
Packit b4291b
    end. Changes all end-of-lines to \r\n. Doesn't encode the data!
Packit b4291b
Packit b4291b
    UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
Packit b4291b
    USE "SendLineEnc" in Mail::Sender INSTEAD!
Packit b4291b
Packit b4291b
FUNCTIONS
Packit b4291b
Packit b4291b
    Mail::Sender implements the following functions.
Packit b4291b
Packit b4291b
 GuessCType
Packit b4291b
Packit b4291b
        my $ctype = Mail::Sender::GuessCType($filename, $filepath);
Packit b4291b
Packit b4291b
    Guesses the content type based on the filename or the file contents.
Packit b4291b
    This function is used when you attach a file and do not specify the
Packit b4291b
    content type. It is not exported by default!
Packit b4291b
Packit b4291b
 MessageID
Packit b4291b
Packit b4291b
        my $id = Mail::Sender::MessageID('from@foo.com');
Packit b4291b
Packit b4291b
    Generates a "unique" message ID for a given from address.
Packit b4291b
Packit b4291b
 ResetGMTdiff
Packit b4291b
Packit b4291b
        Mail::Sender::ResetGMTdiff();
Packit b4291b
Packit b4291b
    The module computes the local vs. GMT time difference to include in the
Packit b4291b
    timestamps added into the message headers. As the time difference may
Packit b4291b
    change due to summer savings time changes you may want to reset the
Packit b4291b
    time difference occasionally in long running programs.
Packit b4291b
Packit b4291b
BUGS
Packit b4291b
Packit b4291b
    I'm sure there are many. Please let me know if you find any.
Packit b4291b
Packit b4291b
    The problem with multi-line responses from some SMTP servers (namely
Packit b4291b
    qmail <http://www.qmail.org/top.html>) is solved at last.
Packit b4291b
Packit b4291b
SEE ALSO
Packit b4291b
Packit b4291b
    Email::Sender
Packit b4291b
Packit b4291b
    There are lots of mail related modules on CPAN. Be wise, use
Packit b4291b
    Email::Sender!
Packit b4291b
Packit b4291b
AUTHOR
Packit b4291b
Packit b4291b
    Jan Krynický <Jenda@Krynicky.cz> http://Jenda.Krynicky.cz
Packit b4291b
Packit b4291b
CONTRIBUTORS
Packit b4291b
Packit b4291b
      * Brian Blakley <bblakley@mp5.net>,
Packit b4291b
Packit b4291b
      * Chase Whitener <capoeirab@cpan.org>,
Packit b4291b
Packit b4291b
      * Ed McGuigan <itstech1@gate.net>,
Packit b4291b
Packit b4291b
      * John Sanche <john@quadrant.net>
Packit b4291b
Packit b4291b
      * Rodrigo Siqueira <rodrigo@insite.com.br>,
Packit b4291b
Packit b4291b
LICENSE AND COPYRIGHT
Packit b4291b
Packit b4291b
    Copyright (c) 1997-2014 Jan Krynický <Jenda@Krynicky.cz>. All rights
Packit b4291b
    reserved.
Packit b4291b
Packit b4291b
    This program is free software; you can redistribute it and/or modify it
Packit b4291b
    under the same terms as Perl itself.
Packit b4291b