$mail_prog = "/usr/sbin/sendmail"; if ($email eq "no") { #Do your html stuff } else { &SendMail($reciptent, $sender); } sub SendMail { my ($recipient,$sender) = @_; open(MAIL, "|$mail_prog -t") || &error("Could not send out emails" ); print MAIL "To: $recipient \n"; print MAIL "From: $sender <$sender>\n"; print MAIL "Subject: database entry\n"; print MAIL "added\n\n"; print MAIL"-----------------------------------------------------------------------------------------\n"; print MAIL ""; print MAIL "\n\n"; print MAIL "\n\n"; close (MAIL); } # end SendMail function