"Fossies" - the Fresh Open Source Software Archive

Member "Mail-Sendmail-0.79_16/test.pl" (24 Aug 2002, 1923 Bytes) of package /linux/privat/old/Mail-Sendmail-0.79_16.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl -w
    2 
    3 # unattended Mail::Sendmail test, sends a message to the author
    4 # but you probably want to change $mail{To} below
    5 # to send the message to yourself.
    6 # version 0.78
    7 
    8 # if you change your mail server, you may need to change the From:
    9 # address below.
   10 $mail{From} = 'Sendmail Test <sendmail@alma.ch>';
   11 
   12 $mail{To}   = 'Sendmail Test <sendmail@alma.ch>';
   13 #$mail{To}   = 'Sendmail Test <sendmail@alma.ch>, You me@myaddress';
   14 
   15 # if you want to get a copy of the test mail, you need to specify your
   16 # own server here, by name or IP address
   17 $server = 'mail.alma.ch';
   18 #$server = 'my.usual.mail.server';
   19 
   20 BEGIN { $| = 1; print "1..2\n"; }
   21 END {print "not ok 1\n" unless $loaded;}
   22 
   23 print <<EOT
   24 Test Mail::Sendmail $Mail::Sendmail::VERSION
   25 
   26 Trying to send a message to the author (and/or whoever if you edited test.pl)
   27 
   28 (The test is designed so it can be run by Test::Harness from CPAN.pm.
   29 Edit it to send the mail to yourself for more concrete feedback. If you
   30 do this, you also need to specify a different mail server, and possibly
   31 a different From: address.)
   32 
   33 Current recipient(s): '$mail{To}'
   34 
   35 EOT
   36 ;
   37 
   38 use Mail::Sendmail;
   39 
   40 $loaded = 1;
   41 print "ok 1\n";
   42 
   43 if ($server) {
   44     $mail{Smtp} = $server;
   45     print "Server set to: $server\n";
   46 }
   47 
   48 $mail{Subject} = "Mail::Sendmail version $Mail::Sendmail::VERSION test";
   49 
   50 $mail{Message} = "This is a test message sent with Perl version $] from a $^O system.\n\n";
   51 $mail{Message} .= "It contains an accented letter: à (a grave).\n";
   52 $mail{Message} .= "It was sent on " . Mail::Sendmail::time_to_date() . "\n";
   53 
   54 # Go send it
   55 print "Sending...\n";
   56 
   57 if (sendmail %mail) {
   58     print "content of \$Mail::Sendmail::log:\n$Mail::Sendmail::log\n";
   59     if ($Mail::Sendmail::error) {
   60         print "content of \$Mail::Sendmail::error:\n$Mail::Sendmail::error\n";
   61     }
   62     print "ok 2\n";
   63 }
   64 else {
   65     print "\n!Error sending mail:\n$Mail::Sendmail::error\n";
   66     print "not ok 2\n";
   67 }