Not sure what you're trying to point out. Class methods don't need an object instance to be called upon.
If you look at the implementation of MIME::Lite::send(),
sub send {
my $self = shift;
my $meth = shift;
if ( ref($self) ) { ### instance method:
my ( $method, @args );
if (@_) { ### args; use them just this once
$method = 'send_by_' . $meth;
@args = @_;
} else { ### no args; use defaults
$method = "send_by_$Sender";
@args = @{ $SenderArgs{$Sender} || [] };
}
$self->verify_data if $AUTO_VERIFY; ### prevents missing pa
+rts!
Carp::croak "Unknown send method '$meth'" unless $self->can($m
+ethod);
return $self->$method(@args);
} else { ### class method:
if (@_) {
my @old = ( $Sender, @{ $SenderArgs{$Sender} } );
$Sender = $meth;
$SenderArgs{$Sender} = [@_]; ### remaining args
return @old;
} else {
Carp::croak "class method send must have HOW... arguments\
+n";
}
}
}
you'll see that in the else branch (### class method), the send method to be set as default is stored in some global variable $Sender together with the arguments in $SenderArgs{$Sender}.
Those values are then being used when send() is called as an instance method.
What makes the program croak is that $self->can($method) is failing, because - apparently - there is no 'send_by_smtp' method in the OP's case. I can't tell why, however — my version of MIME::Lite does have such a method.
|