use CGI::Carp qw(fatalsToBrowser); sub mailFatal { print "Content-type: text/html\n\n"; print "Mail\n"; print "\n"; print "

Mail Server is not available at this time.

\n"; print "

Email down
"; print "\n"; exit; } open (MAIL,"|$sendmail") || mailFatal(); #sendmail stuff here close MAIL || mailFatal();