sub socket { use IO::Socket; $socket = IO::Socket::INET->new(PeerHost => 'Inserisci server', PeerPort => 25, Proto => 'tcp', Debug => 1) || die "Error: $!\n"; if ($socket) { print "Socket ready\n"; &smtp(); } else { print "Error: $!\n"; } } sub smtp{ use Net::SMTP; $smtp = Net::SMTP->new('your.mail.server.com', Hello => 'quellochevuoi', Timeout => 60) || die "Error: $!\n"; $smtp->auth( 'username', 'pass'); $smtp->mail('your@email.com'); print "Insert rcpt:\n"; $rcpt = ; $smtp->to("$rcpt"); $smtp->data(); print "Insert message: \n"; $message = ; $smtp->datasend("Subject: \n"); $smtp->datasend("Cc: \n"); $smtp->datasend("From: your\@email.com\n"); $smtp->datasend("To: $rcpt\n"); $smtp->datasend("$message"); $smtp->datasend("\n"); $smtp->dataend(); $smtp->quit; } &socket();