Haineko::SMTPD::Relay::MX - ESMTP Connection class for sending server listed in MX record or A record
Send an email to external server listed in MX resource record or A resource record using SMTP protocol.
use Haineko::SMTPD::Relay::MX; my $h = { 'Subject' => 'Test', 'To' => 'neko@example.org' }; my $v = { 'ehlo' => '[127.0.0.1]', 'mail' => 'kijitora@example.jp', 'rcpt' => 'neko@example.org', 'head' => $h, 'body' => 'Email message', }; my $e = Haineko::SMTPD::Relay::MX->new( %$v ); my $s = $e->sendmail; print $s; # 0 = Failed to send, 1 = Successfully sent print $e->response->error; # 0 = No error, 1 = Error print $e->response->dsn; # returns D.S.N. value warn Data::Dumper::Dumper $e->response; $VAR1 = bless( { 'dsn' => '2.1.0', 'error' => 0, 'code' => '250', 'host' => 'mx1.example.org', 'port' => 25, 'rcpt' => 'neko@example.org', 'message' => [ '2.0.0 OK Authenticated', '2.1.0 <kijitora@example.jp>... Sender ok' ], 'command' => 'QUIT' }, 'Haineko::SMTPD::Response' ); ``host'' property and ``port'' property will be ignored even if it is defined in etc/mailertable or etc/sendermt. The host is decided by DNS lookup and then try to send the host listed in MX resource records. If Haineko could not connected to the hosts listed in MX, Haineko trys to connect the host listed in A resource record. ``port'' property is always ``25'', ``auth'' and ``starttls'' property is also ignored in this class.
new( %arguments )
new() is a constructor of Haineko::SMTPD::Relay::MX
new()
my $e = Haineko::SMTPD::Relay::MX->new( 'timeout' => 59, # Timeout for Net::SMTP 'debug' => 0, # Debug for Net::SMTP '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 send email to the specified recipient via specified host.
sendmail()
my $e = Haineko::SMTPD::Relay::MX->new( %argvs ); print $e->sendmail; # 0 = Failed to send, 1 = Successfully sent print Dumper $e->response; # Dumps Haineko::SMTPD::Response object
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.