The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Haineko::SMTPD::Relay::ESMTP - ESMTP Connection class

DESCRIPTION

Send an email to external server using SMTP protocol.

SYNOPSIS

    use Haineko::SMTPD::Relay::ESMTP;
    my $h = { 'Subject' => 'Test', 'To' => 'neko@example.org' };
    my $v = { 
        'host' => '192.0.2.1', 
        'port' => 587, 
        'auth' => 1
        'username' => 'user',
        'password' => 'secret',
        'ehlo' => '[127.0.0.1]',
        'mail' => 'kijitora@example.jp',
        'rcpt' => 'neko@example.org',
        'head' => $h,
        'body' => 'Email message',
    };
    my $e = Haineko::SMTPD::Relay::ESMTP->new( %$v );
    my $s = $e->sendmail;

    print $s;                   # 0 = Failed to send, 1 = Successfully sent
    print $e->response->error;  # 0 = No error, 1 = Error
    print $e->response->dsn;    # returns D.S.N. value

    warn Data::Dumper::Dumper $e->response;
    $VAR1 = bless( {
             'dsn' => '2.1.0',
             'error' => 0,
             'code' => '250',
             'rcpt' => 'neko@example.org',
             'host' => '192.0.2.1',
             'port' => 587,
             'message' => [
                    '2.0.0 OK Authenticated',
                    '2.1.0 <kijitora@example.jp>... Sender ok'
                      ],
             'command' => 'QUIT'
            }, 'Haineko::SMTPD::Response' );

CLASS METHODS

new( %arguments )

new() is a constructor of Haineko::SMTPD::Relay::ESMTP

    my $e = Haineko::SMTPD::Relay::ESMTP->new( 
            'host' => '192.0.2.1',          # SMTP Server
            'port' => 587,                  # SMTP Port
            'auth' => 1,                    # Use SMTP-AUTH
            'username' => 'username',       # Username for SMTP-AUTH
            'password' => 'password',       # Password for the user
            'starttls' => 0,                # Use STARTTLS or not
            'timeout' => 59,                # Timeout for Net::SMTP
            'debug' => 0,                   # Debug for Net::SMTP
            'attr' => {                     # Args for Email::MIME
                'content_type' => 'text/plain'
            },
            'head' => {                     # Email header
                'Subject' => 'Test',
                'To' => 'neko@example.org',
            },
            'body' => 'Email message',      # Email body
            'mail' => 'kijitora@example.jp',# Envelope sender
            'rcpt' => 'cat@example.org',    # Envelope recipient
    );

INSTANCE METHODS

sendmail

sendmail() will send email to the specified recipient via specified host.

    my $e = Haineko::SMTPD::Relay::ESMTP->new( %argvs );
    print $e->sendmail;         # 0 = Failed to send, 1 = Successfully sent
    print Dumper $e->response;  # Dumps Haineko::SMTPD::Response object

REPOSITORY

https://github.com/azumakuniyuki/Haineko

AUTHOR

azumakuniyuki <perl.org [at] azumakuniyuki.org>

LICENSE

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