1 #!/usr/local/bin/perl -w
2 # File: date-time.pl
3 # Author: Tom Large - tlarge@thelug.org
4 # Location: http://www.thelug.org/docs/
5 # Description: This script shows a simple method for using perl to send email.
6 # It also illustrates that you can imbed loops for the data section.
7 # Requirements: This script requires the Net::SMTP module. For help, look
8 # to http://www.cpan.org
9
10 use Net::SMTP;
11
12 my $siteSMTP = "156.81.226.38";
13 my $smtp=Net::SMTP->new($siteSMTP);
14 my $opt_f="thomas.a.large\@pbsg.com";
15
16 $counter = 1;
17 @NUM_TEST = ();
18
19 while ($counter < 51)
20 {
21 push(@NUM_TEST, "$counter");
22 $counter++
23 }
24
25 $smtp->mail($opt_f);
26 $smtp->to("someoneelse\@areallyimportantdomainforyoutogetemsailto.com");
27 $smtp->data();
28 $smtp->datasend("From: someone\@areallyimportantdomainforyoutogetemsailto.com\n");
29 $smtp->datasend("Subject: testing loops in smtp\n");
30 $smtp->datasend("To: someoneelse\@areallyimportantdomainforyoutogetemsailto.com\n");
31 $smtp->datasend("---------------------------------------------------------\n");
32 $smtp->datasend("TEST RESULTS\n");
33 $smtp->datasend("Run completed: Should show numbers 1 through 50\n");
34 $smtp->datasend("---------------------------------------------------------\n");
35 foreach $NUM_TEST(@NUM_TEST)
36 {
37 $smtp->datasend("$NUM_TEST\n");
38 }
39 $smtp->datasend("---------------------------------------------------------\n");
40 $smtp->datasend("---------------------------------------------------------\n");
41 $smtp->dataend();
42 $smtp->quit;
syntax highlighted by Code2HTML, v. 0.9.1