azuma, kuniyuki

NAME

Haineko::SMTPD::Relay::File - Just save an email message

DESCRIPTION

Haineko::SMTPD::Relay::File is a dummy connection class for saving an email message to the specified directory or /tmp. This mailer is useful to debug.

SYNOPSIS

    use Haineko::SMTPD::Relay::File;
    my $h = { 'Subject' => 'Test', 'To' => 'neko@example.org' };
    my $v = { 
        'mail' => 'kijitora@example.jp',
        'rcpt' => 'neko@example.org',
        'head' => $h,
        'body' => 'Email message',
    };
    my $e = Haineko::SMTPD::Relay::File->new( %$v );
    my $s = $e->sendmail;

    print $s;                   # 1 = Saved, 0 = Failed to save
    print $e->response->error;  # 0 = Saved, 1 = Failed to save
    print $e->response->dsn;    # D.S.N. is always "undef"

    warn Data::Dumper::Dumper $e->response;
    $VAR1 = bless( {
             'dsn' => undef,
             'error' => 0,
             'code' => '200',
             'host' => undef,
             'port' => undef,
             'rcpt' => 'neko@example.org',
             'message' => [
                '/tmp/haineko.2013-12-25-10:43:11.rBPAhBR70454ovYt.70454.1387935791.079.eml',
                'Successfully saved'
             ],
             'command' => 'DATA'
            }, 'Haineko::SMTPD::Response' );

CLASS METHODS

new( %arguments )

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

    my $e = Haineko::SMTPD::Relay::File->new( 
            '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 save an email to the specified directory or /tmp

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

MAILERTABLE

"File" mailer can be specified in Mailer table file stored in etc/ directory such as mailertable or sendermt as the followings:

mailer: "File"

An email will be saved in /tmp directory.

mailer: "/var/tmp"

An email will be saved in /var/tmp directory. When the specified directory does not exist or cannot be written, Haineko returns error response.

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.




Hosting generously
sponsored by Bytemark