Added two assertions to make sure the handle is defined before using it, and added a check that the handle is defined before releasing it. Also changed the DESTROY method to call its parent.

This commit is contained in:
ian%hixie.ch 2001-11-09 17:07:18 +00:00
Родитель d11f28591a
Коммит 2dc794285b
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -53,6 +53,7 @@ sub init {
sub output {
my $self = shift;
my($app, $session, $string) = @_;
$self->assert(defined($self->handle), 1, 'No SMTP handle, can\'t send mail');
$self->handle->mail('XXX@spam.hixie.ch');
$self->handle->to($session->getAddress('email'));
$self->handle->data($string);
@ -62,11 +63,15 @@ sub output {
sub checkAddress {
my $self = shift;
my($app, $username) = @_;
$self->assert(defined($self->handle), 1, 'No SMTP handle, can\'t check address');
my $result = $self->handle->verify($username);
return $result;
}
sub DESTROY {
my $self = shift;
$self->handle->quit();
if (defined($self->handle)) {
$self->handle->quit();
}
$self->SUPER::DESTROY(@_);
}