My first instinct is that you may be having some timeout issues with the client. You might try sprinkling some print statements throughout your code to see how far it's going. It could be timing out while (or right after) piping to sendmail.
Comment on Re: Problems Trying to Send E-Mail and Insert into Database
My gut says take out the direct call to sendmail
and use Mail::Send instead. They may use sendmail today,
but a little future-proofing and portability never hurts.
Plus it may just solve the problem at hand!