Haineko::SMTPD::Milter - Haineko milter base class
Check or rewrite contents like a milter program at each phase of SMTP session. Each method is called from /submit for example: MAIL -> mail(), RCPT -> rcpt().
mail()
rcpt()
use Haineko::SMTPD::Milter; Haineko::SMTPD::Milter->libs( [ '/path/to/lib1', '/path/to/lib2' ] ); my $x = Haineko::SMTPD::Milter->import( [ 'Neko' ] ); # Load Haineko::SMTPD::Milter::Neko warn Dumper $x; # [ Haineko::SMTPD::Milter::Neko ] my $y = Haineko::SMTPD::Milter->import( [ '+My::Encrypt' ]); # Load My::Encrypt module warn Dumper $y; # [ 'My::Encrypt' ]
libs( [ ... ] )
Add paths in the argument into @INC for finding modules of milter. It may be useful when modules used as a milter are not installed in directories of @INC.
@INC
import( [ ... ] )
Load modules in the argument as a module for milter. If a module name begin with + such as +My::Encrypt, My::Encrypt module will be loaded. A Module which doesn't begin with + such as Neko, ``Haineko::SMTPD::Milter::Neko'' will be loaded.
+
+My::Encrypt
My::Encrypt
Neko
Each method is called from /submit at each phase of SMTP session. If you want to reject the smtp connection, set required values into Haineko::SMTPD::Response object and return 0 or undef as a return value of each method. However you want to only rewrite contents or passed your contents filter, return 1 or true as a return value.
/submit
conn( Haineko::SMTPD::Response, REMOTE_HOST, REMOTE_ADDR )
conn() method is for checking a client hostname and client IP address.
conn()
Haineko::SMTPD::::Response
If your milter program rejects a message, set 1 by ->error(1), set error message by ->message( [ 'Error message' ]), and override SMTP status code by ->code(), Default SMTP status codes is 421 in this method.
REMOTE_HOST
The host name of the message sender, as picked from HTTP REMOTE_HOST variable.
REMOTE_ADDR
The host address, as picked from HTTP REMOTE_ADDR variable.
ehlo( Haineko::SMTPD::Response, HELO_HOST )
ehlo() method is for checking a hostname passed as an argument of EHLO.
ehlo()
EHLO
Haineko::SMTPD::Response
If your milter program rejects a message, set 1 by ->error(1), set error message by ->message( [ 'Error message' ]), and override SMTP status code by ->code(), override D.S.N value by ->dsn(). Default SMTP status codes is 521 in this method.
HELO_HOST
Value defined in ehlo field in HTTP POST JSON data, which should be the domain name of the sending host or IP address enclosed square brackets.
ehlo
HTTP POST
mail( Haineko::SMTPD::Response, ENVELOPE_SENDER )
mail() method is for checking an envelope sender address.
If your milter program rejects a message, set 1 by ->error(1), set error message by ->message( [ 'Error message' ]), and override SMTP status code by ->code(), override D.S.N value by ->dsn(). Default SMTP status codes is 501, dsn is 5.1.8 in this method.
Value defined in "mail" field in HTTP POST JSON data, which should be the valid email address.
rcpt( Haineko::SMTPD::Response, ENVELOPE_RECIPIENT )
rcpt() method is for checking envelope recipient address.
If your milter program rejects a message, set 1 by ->error(1), set error message by ->message( [ 'Error message' ]), and override SMTP status code by ->code(), override D.S.N value by ->dsn(). Default SMTP status codes is 553, dsn is 5.7.1 in this method.
Values defined in rcpt field in HTTP POST JSON data, which should be the valid email address.
rcpt
head() method is for checking email header. Email header is password as an hash reference.
head()
If your milter program rejects a message, set 1 by ->error(1), set error message by ->message( [ 'Error message' ]), and override SMTP status code by ->code(), override D.S.N value by ->dsn(). Default SMTP status codes is 554, dsn is 5.7.1 in this method.
Values defined in "header" field in HTTP POST JSON data.
body( Haineko::SMTPD::Response, \EMAIL_BODY )
body() method is for checking email body. Email body is password as an scalar reference.
body()
If your milter program rejects a message, set 1 by ->error(1), set error message by ->message( [ 'Error message' ]), and override SMTP status code by ->code(), override D.S.N value by ->dsn(). Default SMTP status codes is 554, dsn is 5.6.0 in this method.
Value defined in "body" field in HTTP POST JSON data.
https://www.milter.org/developers/api/
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.