Tripletail

 view release on metacpan or  search on metacpan

lib/Tripletail/Sendmail/Smtp.pm  view on Meta::CPAN

# -----------------------------------------------------------------------------
# Tripletail::Sendmail::Smtp - SMTPメール送信
# -----------------------------------------------------------------------------
package Tripletail::Sendmail::Smtp;
use strict;
use warnings;
use Tripletail;
use IO::Socket::INET;
use base 'Tripletail::Sendmail';

1;

sub _new {
	my $class = shift;
	my $group = shift;
	my $this = bless {} => $class;

	$this->{group  } = $group;
	$this->{timeout} = $TL->INI->get($group => timeout => 300        );
	$this->{host   } = $TL->INI->get($group => host    => 'localhost');
	$this->{log    } = $TL->INI->get($group => logging => undef      );
	$this->{sock   } = undef;
	$this->{status } = undef;

	$this->{timeout_period} = $TL->parsePeriod($this->{timeout});

	$this;
}

sub setTimeout {
	my $this = shift;
	my $sec = shift;

	if(ref($sec)) {
		die __PACKAGE__."#setTimeout: arg[1] is a reference. [$sec] (第1引数がリファレンスです)\n";
	}

	$this->{timeout} = $sec;
	$this->{timeout_period} = $TL->parsePeriod($this->{timeout});
	$this;
}

sub connect {
	my $this = shift;
	my $host = shift;

	if(!defined($host)) {
		# iniで指定されたものを使う
		$host = $this->{host};
	} elsif(ref($host)) {
		die __PACKAGE__."#connect: arg[1] is a reference. [$host] (第1引数がリファレンスです)\n";
	}

	$this->_connect($host);
	$this->_hello;

	$this;
}

sub disconnect {
	my $this = shift;

	$this->_quit;
	$this->_disconnect;

	$this;
}

sub send {
	my $this = shift;
	my $data = $this->_getoptSend(@_);

	$this->_reset;

	# send from



( run in 0.909 second using v1.01-cache-2.11-cpan-63c85eba8c4 )