SMTP client send fake e-mail
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 = <STDIN>; $smtp->to("$rcpt"); $smtp->data(); print "Insert message: \n"; $message = <STDIN>; $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();

Replies are listed 'Best First'.
Re: Command-line SMTP client
by csuhockey3 (Curate) on Jul 18, 2004 at 17:11 UTC
    I have actually found many uses for this -- I modified it a bit to help with testing in a staging environment and it works nicely. Thanks for a little inspiration, actually turned out to be a bit of a timesaver and more reliable.

    CSUhockey3