use Mail::Sendmail; sub attach { my $f = shift; my $boundary = "====" . time() . "===="; $f->{body} = encode_qp( $f->{message} ); $f->{from} = 'test@thesite.org'; delete($f->{message}); $f->{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; $boundary = '--'.$boundary; $f->{body} = <{body} HEAD while ( my($file,$data) = each %{$f->{attachment}}){ $f->{body} .= <{attachment}); sendmail(%$f); }