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.


In reply to Re^4: Getting Error "Unknown send method" when sending mail using MIME::Lite?? by almut
in thread Getting Error "Unknown send method" when sending mail using MIME::Lite?? by Sachin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.