#!/usr/bin/perl -w # Hugh Brown # Nov 2, 2006 # Version 1.0 # # testmail.pl: A Small but Useful(tm) utility to send test messages # via telnet. Expanded (such as it is) from this article: # # http://open.itworld.com/nl/unix_sys_adm/08282002/ # # Copyright (C) 2006 Hugh Brown # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # # $Id: testmail.pl,v 1.1 2006/11/02 19:25:20 hugh Exp $ use strict; use Getopt::Std; use Net::Telnet; sub usage { print < 30, Port => 25, input_log => $fh, output_log => $fh, Errmode => 'die'); my $output; $telnet->open($server); $telnet->dump_log(); $telnet->waitfor('/220/'); $telnet->print('HELO just-testing.example.com'); $telnet->waitfor('/250/'); $telnet->print("MAIL FROM: <$from>"); $telnet->waitfor('/250/'); $telnet->print("RCPT TO: <$to>"); $telnet->waitfor('/250/'); $telnet->print("DATA"); $telnet->waitfor('/354/'); $telnet->print("Subject: Test\nFrom: $from\nTo: $to\n\nTest\n."); $telnet->waitfor('/250/'); $telnet->print('QUIT');