in reply to Using The Mail::Sendmail module in CGI Script

The error is coming from this block of code in Mail::Sendmail:
unless ( socket S, AF_INET, SOCK_STREAM, scalar(getprotobyname + 'tcp') ) { return fail("socket failed ($!)") }
What this means is that the error occurs when the system is creating a socket, but before it attempts to connect to anything.

Are you running fedora? This sounds like a problem with SELINUX preventing the script from creating a socket.