Net::SMTP?

Robert L. Harris Robert.L.Harris at rdlg.net
Tue Jul 24 14:51:36 CDT 2001



I'm trying to use Net::SMTP and I'm not getting any output.  Here's a
chunk of code:


#!/usr/local/bin/perl -w

use strict;
use diagnostics;
use Net::SMTP;

#
# Do some data gathering
#
.
.
.
#


if (@Down) {
  &SendMailNotification(@Down);
}

exit 0;

########################
# Sub Procs below here #
########################
sub SendMailNotification {
  my (@Down)=@_;
  my ($Hostname)=`hostname`;
  my ($MailSubject)="GonzoProblems on $Hostname";
  my ($MailTo)="robert\@rdlg.net";
  my ($i);

  print "We had a problem so we'll send mail.\n";

  $smtp = Net::SMTP->new('mailgw2.rdlg.net.');

  $smtp->mail('GonzoChecker\@$Hostname');
  $smtp->to('robert at rdlg.net');

  $smtp->data();
  $smtp->datasend("Subject: GonzoProblems on $Hostname\n");
  $smtp->datasend("\n");
  $smtp->datasend("Could not connect to:\n");
  foreach $i (@Down) {
    $smtp->datasend("$i\n");
  }
  $smtp->dataend();

  $smtp->quit;

#  open (SENDMAIL, "| /usr/bin/mailx -v -s \"$MailSubject\" $MailTo");
#
#  print "Could not connect to:\n";
#  print SENDMAIL "Could not connect to:\n";
#  foreach $i (@Down) {
#    print "  $i\n";
#    print SENDMAIL "  $i\n";
#  }
#  close(SENDMAIL);
}

If I comment out the $smtp portion, and uncomment the other, it works just
fine.


:wq!
---------------------------------------------------------------------------
Robert L. Harris                |  Micros~1 :  
Senior System Engineer          |    For when quality, reliability 
  at RnD Consulting             |      and security just aren't
                                \_       that important!
DISCLAIMER:
      These are MY OPINIONS ALONE.  I speak for no-one else.
FYI:
 perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'




More information about the Pikes-peak-pm mailing list