# Mail::Internet.pm
#
# Copyright (c) 1995-2001 Graham Barr <gbarr@pobox.com>. All rights reserved.
# Copyright (c) 2002-2003 Mark Overmeer <mailtools@overmeer.net>
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#

package Mail::Internet;
use strict;

require 5.002;

use Carp;
use AutoLoader;
use Mail::Header;
use vars qw($VERSION);

BEGIN {
    $VERSION = "1.58";
    *AUTOLOAD = \&AutoLoader::AUTOLOAD;

    unless(defined &UNIVERSAL::isa) {
	*UNIVERSAL::isa = sub {
	    my($obj,$type) = @_;
	    my $pkg = ref($obj) || $obj;
	    my @pkg = ($pkg);
	    my %done;
	    while(@pkg) {
        	$pkg = shift @pkg;
		return 1 if $pkg eq $type;
        	next if exists $done{$pkg};
        	$done{$pkg} = 1;

		no strict 'refs';

        	unshift @pkg,@{$pkg . "::ISA"}
        	    if(@{$pkg . "::ISA"});
	    }
	    undef;
	}
    }
}


sub body
{
 my $me = shift;
 my $body = $me->{'mail_inet_body'} ||= [];

 if(@_)
  {
   my $new = shift;
   $me->{'mail_inet_body'} = ref($new) eq 'ARRAY' ? $new : [ $new, @_ ];
  }

 return $body;
}

sub header { shift->head->header(@_) }
sub head { shift->{'mail_inet_head'} ||= new Mail::Header }

sub as_string
{
 my $me = shift;

 $me->head->as_string . "\n" . join '', @{ $me->body };
}

sub DESTROY {}
