Mail-Sender

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    through an SMTP server

DEPRECATED

    Mail::Sender is deprecated. Email::Sender is the go-to choice when you
    need to send Email from Perl. Go there, be happy!

SYNOPSIS

      use Mail::Sender;
    
      my $sender = Mail::Sender->new({
        smtp => 'mail.yourdomain.com',
        from => 'your@address.com'
      });
      $sender->MailFile({
        to => 'some@address.com',
        subject => 'Here is the file',
        msg => "I'm sending you the list you wanted.",
        file => 'filename.txt'
      });

DESCRIPTION

    Mail::Sender is deprecated. Email::Sender is the go-to choice when you
    need to send Email from Perl. Go there, be happy!

    Mail::Sender provides an object-oriented interface to sending mails. It
    directly connects to the mail server using IO::Socket.

ATTRIBUTES

    Mail::Sender implements the following attributes.

    * Please note that altering an attribute after object creation is best
    handled with creating a copy using $sender = $sender->new({attribute =>
    'value'}). To obtain the current value of an attribute, break all the
    rules and reach in there! my $val = $sender->{attribute};

 auth

        # mutating single attributes could get costly!
        $sender = $sender->new({auth => 'PLAIN'});
        my $auth = $sender->{auth}; # reach in to grab

    The SMTP authentication protocol to use to login to the server
    currently the only ones supported are LOGIN, PLAIN, CRAM-MD5 and NTLM.
    Some protocols have module dependencies. CRAM-MD5 depends on
    Digest::HMAC_MD5 and NTLM on Authen::NTLM.

    You may add support for other authentication protocols yourself.

 auth_encoded

        # mutating single attributes could get costly!
        $sender = $sender->new({auth_encoded => 1});
        my $auth_enc = $sender->{auth_encoded}; # reach in to grab

    If set to a true value, Mail::Sender attempts to use TLS (encrypted
    connection) whenever the server supports it and you have
    IO::Socket::SSL and Net::SSLeay.

    The default value of this option is true! This means that if
    Mail::Sender can send the data encrypted, it will.

 authdomain

        # mutating single attributes could get costly!
        $sender = $sender->new({authdomain => 'bar.com'});
        my $domain = $sender->{authdomain}; # reach in to grab

    The domain name; used optionally by the NTLM authentication. Other
    authentication protocols may use other options as well. They should all
    start with auth though.

 authid

        # mutating single attributes could get costly!
        $sender = $sender->new({authid => 'username'});
        my $username = $sender->{authid}; # reach in to grab

    The username used to login to the server.

 authpwd

        # mutating single attributes could get costly!
        $sender = $sender->new({authpwd => 'password'});
        my $password = $sender->{authpwd}; # reach in to grab

    The password used to login to the server.

 bcc

        # mutating single attributes could get costly!
        $sender = $sender->new({bcc => 'foo@bar.com'});
        $sender = $sender->new({bcc => 'foo@bar.com, bar@baz.com'});
        $sender = $sender->new({bcc => ['foo@bar.com', 'bar@baz.com']});
        my $bcc = $sender->{bcc}; # reach in to grab

    Send a blind carbon copy to these addresses.

 boundary

        # mutating single attributes could get costly!
        $sender = $sender->new({boundary => '--'});
        my $boundary = $sender->{boundary}; # reach in to grab

    The message boundary. You usually do not have to change this, it might
    only come in handy if you need to attach a multi-part mail created by
    Mail::Sender to your message as a single part. Even in that case any
    problems are unlikely.

 cc

        # mutating single attributes could get costly!
        $sender = $sender->new({cc => 'foo@bar.com'});
        $sender = $sender->new({cc => 'foo@bar.com, bar@baz.com'});
        $sender = $sender->new({cc => ['foo@bar.com', 'bar@baz.com']});
        my $cc = $sender->{cc}; # reach in to grab

    Send a carbon copy to these addresses.

README  view on Meta::CPAN

    parameter may be either a string containing the headers in the right
    format or a hash containing the headers and their values.

 keepconnection

        # mutating single attributes could get costly!
        $sender = $sender->new({keepconnection => 1);
        $sender = $sender->new({keepconnection => 0});
        my $keepcon = $sender->{keepconnection}; # reach in to grab

    If set to a true value, it causes the Mail::Sender to keep the
    connection open for several messages. The connection will be closed if
    you call the "Close" in Mail::Sender method with a true value or if you
    call "Open" in Mail::Sender, "OpenMultipart" in Mail::Sender, "MailMsg"
    in Mail::Sender or "MailFile" in Mail::Sender with the smtp attribute.
    This means that if you want the object to keep the connection, you
    should pass the smtp either to "new" in Mail::Sender or only to the
    first "Open" in Mail::Sender, "OpenMultipart" in Mail::Sender,
    "MailMsg" in Mail::Sender or "MailFile" in Mail::Sender!

 multipart

        # mutating single attributes could get costly!
        $sender = $sender->new({multipart => 'Mixed'});
        my $multi = $sender->{multipart}; # reach in to grab

    The MIME subtype for the whole message (Mixed/Related/Alternative). You
    may need to change this setting if you want to send an HTML body with
    some inline images, or if you want to post the message in plain text as
    well as HTML (alternative).

 on_errors

        # mutating single attributes could get costly!
        $sender = $sender->new({on_errors => 'undef'}); # return undef on error
        $sender = $sender->new({on_errors => 'die'}); # raise an exception
        $sender = $sender->new({on_errors => 'code'}); # return the negative error code (default)
        # -1 = $smtphost unknown
        # -2 = socket() failed
        # -3 = connect() failed
        # -4 = service not available
        # -5 = unspecified communication error
        # -6 = local user $to unknown on host $smtp
        # -7 = transmission of message failed
        # -8 = argument $to empty
        # -9 = no message specified in call to MailMsg or MailFile
        # -10 = no file name specified in call to SendFile or MailFile
        # -11 = file not found
        # -12 = not available in singlepart mode
        # -13 = site specific error
        # -14 = connection not established. Did you mean MailFile instead of SendFile?
        # -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 = all recipients were rejected by the server
        # -21 = file specified as an attachment cannot be read
        # -22 = failed to open the specified debug file for writing
        # -23 = STARTTLS failed (for SSL or TLS encrypted connections)
        # -24 = IO::Socket::SSL->start_SSL failed
        # -25 = TLS required by the specified options, but the required modules are not available. Need IO::Socket::SSL and Net::SSLeay
        # -26 = TLS required by the specified options, but the server doesn't support it
        # -27 = unknown encoding specified for the mail body, part or attachment. Only base64, quoted-printable, 7bit and 8bit supported.
        my $on_errors = $sender->{on_errors}; # reach in to grab
        say $Mail::Sender::Error; # contains a textual description of last error.

    This option allows you to affect the way Mail::Sender reports errors.
    All methods return the $sender object if they succeed.

    $Mail::Sender::Error $sender->{'error'} and $sender->{'error_msg'} are
    set in all cases.

 port

        # mutating single attributes could get costly!
        $sender = $sender->new({port => 25});
        my $port = $sender->{port}; # reach in to grab

    The TCP/IP port used form the connection. By default
    getservbyname('smtp', 'tcp')||25. You should only need to use this
    option if your mail server waits on a nonstandard port.

 priority

        # mutating single attributes could get costly!
        $sender = $sender->new({priority => 1});
        # 1. highest
        # 2. high
        # 3. normal
        # 4. low
        # 5. lowest
        my $priority = $sender->{priority}; # reach in to grab

    The message priority number.

 replyto

        # mutating single attributes could get costly!
        $sender = $sender->new({replyto => 'foo@bar.com'});
        my $replyto = $sender->{replyto}; # reach in to grab

    The reply to address.

 skip_bad_recipients

        # mutating single attributes could get costly!
        $sender = $sender->new({skip_bad_recipients => 1);
        $sender = $sender->new({skip_bad_recipients => 0});
        my $skip = $sender->{skip_bad_recipients}; # reach in to grab

    If this option is set to false, or not specified, then Mail::Sender
    stops trying to send a message as soon as the first recipient's address
    fails. If it is set to a true value, Mail::Sender skips the bad
    addresses and tries to send the message at least to the good ones. If
    all addresses are rejected by the server, it reports a All recipients
    were rejected message.

    If any addresses were skipped, the $sender->{'skipped_recipients'} will
    be a reference to a hash containing the failed address and the server's
    response.

 smtp

        # mutating single attributes could get costly!
        $sender = $sender->new({smtp => 'smtp.bar.com'});
        my $smtp = $sender->{smtp}; # reach in to grab

    The IP address or domain of your SMTP server.

 ssl_...

    The ssl_version, ssl_verify_mode, ssl_ca_path, ssl_ca_file,
    ssl_verifycb_name, ssl_verifycn_schema and ssl_hostname options (if
    specified) are passed to "start_SSL" in IO::Socket::SSL. The default
    version is TLSv1 and verify mode is IO::Socket::SSL::SSL_VERIFY_NONE.

    If you change the ssl_verify_mode to SSL_VERIFY_PEER, you may need to
    specify the ssl_ca_file. If you have Mozilla::CA installed, then
    setting it to Mozilla::CA::SSL_ca_file() may help.

 subject

        # mutating single attributes could get costly!
        $sender = $sender->new({subject => 'An email is coming!'});
        my $subject = $sender->{subject}; # reach in to grab

    The subject of the message.

 tls_allowed

        # mutating single attributes could get costly!
        $sender = $sender->new({tls_allowed => 1}); # true, default
        $sender = $sender->new({tls_allowed => 0}); # false
        my $tls = $sender->{tls_allowed}; # reach in to grab

    If set to a true value, Mail::Sender will attempt to use TLS (encrypted
    connection) whenever the server supports it. This requires that you
    have IO::Socket::SSL and Net::SSLeay.

 tls_required

        # mutating single attributes could get costly!
        $sender = $sender->new({tls_required => 1}); # true, require TLS encryption
        $sender = $sender->new({tls_required => 0}); # false, plain. default
        my $required = $sender->{tls_required};

    If you set this option to a true value, the module will fail if it's
    unable to use TLS.

 to

        # mutating single attributes could get costly!
        $sender = $sender->new({to => 'foo@bar.com'});
        $sender = $sender->new({to => 'foo@bar.com, bar@baz.com'});
        $sender = $sender->new({to => ['foo@bar.com', 'bar@baz.com']});
        my $to = $sender->{to}; # reach in to grab

    The recipient's addresses. This parameter may be either a comma
    separated list of email addresses or a reference to a list of
    addresses.

METHODS

    Mail::Sender implements the following methods.

 Attach

        # set parameters in an ordered list
        # -- description, ctype, encoding, disposition, file(s)
        $sender = $sender->Attach(
            'title', 'application/octet-stream', 'Base64', 'attachment; filename=*', '/file.txt'
        );
        $sender = $sender->Attach(
            'title', 'application/octet-stream', 'Base64', 'attachment; filename=*',
            ['/file.txt', '/file2.txt']
        );
        # OR use a hashref
        $sender = $sender->Attach({
            description => 'some title',
            charset => 'US-ASCII', # default
            encoding => 'Base64', # default
            ctype => 'application/octet-stream', # default
            disposition => 'attachment; filename=*', # default
            file => ['/file1.txt'], # file names
            content_id => '#', # for auto-increment number, or * for filename
        });

    Sends a file as a separate part of the mail message. Only in multi-part
    mode.

 Body

        # set parameters in an ordered list
        # -- charset, encoding, content-type
        $sender = $sender->Body('US-ASCII', '7BIT', 'text/plain');
        # OR use a hashref
        $sender = $sender->Body({
            charset => 'US-ASCII', # default



( run in 2.798 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )