Haineko::SMTPD::Relay::File - Just save an email message
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.
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' );
new( %arguments )
new() is a constructor of Haineko::SMTPD::Relay::File
new()
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 );
sendmail
sendmail() will save an email to the specified directory or /tmp
sendmail()
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
"File" mailer can be specified in Mailer table file stored in etc/ directory such as mailertable or sendermt as the followings:
mailertable
sendermt
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.
https://github.com/azumakuniyuki/Haineko
azumakuniyuki <perl.org [at] azumakuniyuki.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Haineko, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Haineko
CPAN shell
perl -MCPAN -e shell install Haineko
For more information on module installation, please visit the detailed CPAN module installation guide.