Net::SMTP?
Keary Suska
aksuska at webflyer.com
Tue Jul 24 15:29:23 CDT 2001
The only thing I can see is that your "from" address is invalid.
> $smtp->mail('GonzoChecker\@$Hostname');
Because the string is in single quotes, interpolation is not performed, so
the address is literally "GonzoChecker\@$Hostname" and not
"GonzoChecker at whateverhost.com" as you may expect. Perhaps Net::SMTP is
choking on the address because it is malformed. You could turn on the debug
option and see what is generated. The mail() method should return a status
of some kind, at least false on failure, which you could check for as well.
Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"
> From: "Robert L. Harris" <Robert.L.Harris at rdlg.net>
> Date: Tue, 24 Jul 2001 13:51:36 -0600
> To: Pikes-Peak Perl Mongers <pikes-peak-pm-list at happyfunball.pm.org>
> Subject: Net::SMTP?
>
>
>
> 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