Haineko
view release on metacpan or search on metacpan
### etc/mailertable
Defines "mailer table": Recipient's domain part based routing table like the
same named file in Sendmail. This file is taken precedence over the routing
table defined in etc/sendermt for deciding the mailer.
### etc/sendermt
Defines "mailer table" which decide the mailer by sender's domain part.
### etc/authinfo
Provide credentials for client side authentication information.
Credentials defined in this file are used at relaying an email to external
SMTP server.
__This file should be set secure permission: The only user who runs haineko server
can read this file.__
### etc/relayhosts
Permitted hosts or network table for relaying via /submit.
### etc/recipients
etc/authinfo-example view on Meta::CPAN
# _ _ _ __
# __ _ _ _| |_| |__ (_)_ __ / _| ___
# / _` | | | | __| '_ \| | '_ \| |_ / _ \
# | (_| | |_| | |_| | | | | | | | _| (_) |
# \__,_|\__,_|\__|_| |_|_|_| |_|_| \___/
#
# Desciption: authinfo provide credentials for client side authentication
# information. Credentials defined in this file are used at relaying
# an email to external SMTP server.
# Syntax:
# key:
# username: Username for SMTP-AUTH
# password: Password for the user
#
# Example:
# kijitora-smtpd:
# username: 'kijitora'
etc/mailertable-example view on Meta::CPAN
# | | | | | | (_| | | | __/ | | || (_| | |_) | | __/
# |_| |_| |_|\__,_|_|_|\___|_| \__\__,_|_.__/|_|\___|
#
# Description: Recipient based routing table
# Syntax:
# domain-part-of-recipient:
# mailer: "ESMTP" or a module name stored in lib/Haineko/SMTPD/Relay/ such
# as 'SendGrid' or 'MX'.
# host: SMTP server for relaying, default value is 127.0.0.1
# port: Port number of the server, default value is 25.
# auth: 'key' = Use SMTP-AUTH in relaying by using credentials defined
# in etc/authinfo
# '' = No SMTP-AUTH
# retry: Retry count when an SMTP server returns 4XX.
# sleep: Sleep for specified seconds until the next retrying
# timeout: Seconds until timeout for SMTP connection
# starttls: 1 = Use STARTTLS at SMTP connection
# 0 = Do not use STARTTLS
# disabled: 1 = Do not use this routing
# 0 = Use this routing
#
etc/sendermt-example view on Meta::CPAN
# \__ \ __/ | | | (_| | __/ | | | | | | | |_
# |___/\___|_| |_|\__,_|\___|_| |_| |_| |_|\__|
#
# Description: Sender based routing table
# Syntax:
# domain-part-of-sender:
# mailer: "ESMTP" or a module name stored in lib/Haineko/SMTPD/Relay/ such
# as 'SendGrid' or 'MX'.
# host: SMTP server for relaying, default value is 127.0.0.1
# port: Port number of the server, default value is 25.
# auth: 'key' = Use SMTP-AUTH in relaying by using credentials defined
# in etc/authinfo
# '' = No SMTP-AUTH
# retry: Retry count when an SMTP server returns 4XX.
# sleep: Sleep for specified seconds until the next retrying
# timeout: Seconds until timeout for SMTP connection
# starttls: 1 = Use STARTTLS at SMTP connection
# disabled: 1 = Do not use this routing
# 0 = Use this routing
#
# Example:
lib/Haineko.pm view on Meta::CPAN
Defines "mailer table": Recipient's domain part based routing table like the
same named file in Sendmail. This file is taken precedence over the routing
table defined in C<etc/sendermt> for deciding the mailer.
=head2 C<etc/sendermt>
Defines "mailer table" which decide the mailer by sender's domain part.
=head2 C<etc/authinfo>
Provide credentials for client side authentication information. Credentials
defined in this file are used at relaying an email to external SMTP server.
This file should be set secure permission: The only user who runs haineko server
can read this file.
=head2 C<etc/relayhosts>
Permitted hosts or network table for relaying via C</submit>.
=head2 C<etc/recipients>
lib/Haineko/SMTPD/Relay/Haineko.pm view on Meta::CPAN
$parameters->{'header'}->{'replyto'} = $self->{'head'}->{'Reply-To'};
}
my $jsonstring = Haineko::JSON->dumpjson( $parameters );
my $httpheader = [];
my $httpobject = undef;
my $htresponse = undef;
my $hainekores = undef;
if( $self->{'username'} && $self->{'password'} ) {
# Encode credentials for Basic-Authentication
require MIME::Base64;
my $v = MIME::Base64::encode_base64( $self->{'username'}.':'.$self->{'password'} );
$httpheader = [ 'Authorization' => sprintf( "Basic %s", $v ) ];
}
$httpobject = Furl->new(
'agent' => __PACKAGE__,
'timeout' => 10,
'headers' => $httpheader,
'ssl_opts' => { 'SSL_verify_mode' => 0 }
lib/Haineko/Sendmail.pm view on Meta::CPAN
# Mail Exchanger is waiting on *:25
$methodargv->{'port'} = 25;
$methodargv->{'debug'} = $relayingto->{'debug'} // 0;
}
$relayclass = sprintf( "Haineko::SMTPD::Relay::%s", $relayingto->{'mailer'} );
Module::Load::load( $relayclass );
$smtpmailer = $relayclass->new( %$methodargv );
if( $relayingto->{'auth'} ) {
# Load credentials for SMTP-AUTH
$smtpmailer->auth( 1 );
$smtpmailer->username( $credential->{'username'} );
$smtpmailer->password( $credential->{'password'} );
}
$smtpmailer->sendmail();
} elsif( $relayingto->{'mailer'} =~ m/(?:Discard|Screen)/ ) {
# These mailer does not open new connection to any host.
# Haineko::SMTPD::Relay::
lib/Haineko/Sendmail.pm view on Meta::CPAN
if( length $relayingto->{'mailer'} ) {
# Use Haineko::SMTPD::Relay::* except H::S::R::ESMTP,
# H::S::R::Haineko and H::S::R::Discard.
try {
$relayclass = sprintf( "Haineko::SMTPD::Relay::%s", $relayingto->{'mailer'} );
Module::Load::load( $relayclass );
$smtpmailer = $relayclass->new( %$methodargv );
if( $relayingto->{'auth'} ) {
# Load credentials for SMTP-AUTH
$smtpmailer->auth( 1 );
$smtpmailer->username( $credential->{'username'} );
$smtpmailer->password( $credential->{'password'} );
}
$smtpmailer->sendmail();
if( not $smtpmailer->response->dsn ) {
# D.S.N. is empty or undefined.
if( $smtpmailer->response->error ) {
( run in 0.290 second using v1.01-cache-2.11-cpan-4d50c553e7e )