my $body = .... my $attach = .... # base 64 encoded data my $a_name = ..... my $email =<datasend($email) $smtp->dataend() $smtp->quit;