NAME

Haineko::SMTPD::Session - HTTP to SMTP Session class

DESCRIPTION

Haineko::SMTPD::Session manages a connection from HTTP and SMTP session on Haineko server.

SYNOPSIS

use Haineko::SMTPD::Session;
my $v = { 
    'useragent' => 'Mozilla',
    'remoteaddr' => '127.0.0.1',
    'remoteport' => 62401,
};
my $e = Haineko::SMTPD::Session->new( %$v );
$e->addresser( 'kijitora@example.jp' );
$e->recipient( [ 'neko@example.org' ] );

print $e->queueid;              # r64CvGQ21769QslMmPPuD2jC
print $e->started;              # Thu Jul  4 18:00:00 2013 (Time::Piece object)
print $e->addresser->user;      # kijitora (Haineko::SMTPD::Address object)
print $e->recipient->[0]->host; # example.org (Haineko::SMTPD::Address object)

CLASS METHODS

new( %arguments )

new() is a constructor of Haineko::SMTPD::Session

my $e = Haineko::SMTPD::Session->new( 
        'useragent' => $self->req->headers->user_agent,
        'remoteaddr' => $self->req->headers->header('REMOTE_HOST'),
        'remoteport' => $self->req->headers->header('REMOTE_PORT'),
        'addresser' => 'kijitora@example.jp',
        'recipient' => [ 'neko@example.org', 'cat@example.com' ],
);

load( Hash reference )

load() is also a constructor of Haineko::SMTPD::Session.

my $v = {
    'queueid' => 'r64CvGQ21769QslMmPPuD2jC',
    'addresser' => 'kijitora@example.jp',
};
my $e = Haineko::SMTPD::Session->load( %$v );

print $e->queueid;              # r64CvGQ21769QslMmPPuD2jC
print $e->addresser->address;   # kijitora@example.jp

make_queueid

make_queueid() generate a queue id string.

print Haineko::SMTPD::Session->make_queueid;   # r64IHFV22109f8KATxdNDSj7
print Haineko::SMTPD::Session->make_queueid;   # r64IHJP22111Q9PCwpWX1Pd0
print Haineko::SMTPD::Session->make_queueid;   # r64IHV622112od227ioJMxhh

INSTANCE METHODS

r( SMTP command, Error type [,Message] )

r() sets Haineko::SMTPD::Response object from a SMTP Command and an error type.

my $e = Haineko::SMTPD::Session->new( ... );
print $e->response->dsn;    # undef

$e->r( 'RCPT', 'rejected' );
print $e->response->dsn;    # 5.7.1
print $e->response->code;   # 553

damn

damn() returns instance data as a hash reference

warn Data::Dumper::Dumper $e;
$VAR1 = {
      'referer' => undef,
      'queueid' => 'r64IQ9X22396oA0bjQZIU7rn',
      'addresser' => 'kijitora@example.jp',
      'response' => {
            'dsn' => undef,
            'error' => undef,
            'message' => undef,
            'command' => undef,
            'code' => undef
      },
      'remoteaddr' => '127.0.0.1',
      'useragent' => 'CLI',
      'timestamp' => {
            'unixtime' => 1372929969,
            'datetime' => "Wed Jul 17 12:00:27 2013"
      },
      'stage' => 4,
      'remoteport' => 1024
    };

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.