I have been using Mail::Sendmail with great results until recently. Making things odd is that a Sendmail-using year-plus old compiled EXE (using perlapp) still works. Making things really infuriating is that while I was away for a year the source for the compiled EXE was lost. The patient presents as follows:
The config section of my sendmail.pm file:
$VERSION = '0.78';
# *************** Configuration you may want to change *******************
# You probably want to set your SMTP server here (unless you specify it in
# every script), and leave the rest as is. See pod documentation for details
%mailcfg = (
# List of SMTP servers:
#'smtp' => [ qw( localhost ) ],
#'smtp' => [ qw( mail.mydomain.com ) ], # example
'smtp' => [ qw( my_server_name.eglin.af.mil ) ],
'smtp' => [ qw( my-workstation-name.eglin.af.mil ) ],
'from' => 'ESC/ACU OL-1 Master <[EMAIL PROTECTED]>', # default sender e-mail, used when no From header in mail
'mime' => 1, # use MIME encoding by default
'retries' => 1, # number of retries on smtp connect failure
'delay' => 1, # delay in seconds between retries
'tz' => '', # only to override automatic detection
'port' => 25, # change it if you always use a non-standard port
'debug' => 0 # prints stuff to STDERR
);
#########################################################################################
This script:
#########################################################################################
#!c:/Perl/bin/perl.exe -w
use Mail::Sendmail;
$mail{From} = '[EMAIL PROTECTED]';
$mail{To} = '[EMAIL PROTECTED]';
$mail{Subj} = 'test';
$mail{Text} = "I am a test message";
$mail{Date} = Mail::Sendmail::time_to_date( time() );
sendmail(%mail) or die I am dead;
#########################################################################################
yields these results:
#########################################################################################
Unquoted string "dead" may clash with future reserved word at \\web-mplan\admins
cripts\simmail.pl line 10.
retrying in 1 seconds...
connect to my-workstation-name.eglin.af.mil failed (Unknown error) no (more) retries!C
an't locate object method "I" via package "am" (perhaps you forgot to load "am"?
) at \\my_server_name\adminscripts\simmail.pl line 10.
#########################################################################################
This script:
#########################################################################################
#!c:/perl/bin/perl.exe -w
# Script edited down to Sendmail relevant portions, although 'use's are left in for conflict detection
# Import the Win32API modules User symbols.
use Win32API::Net qw(:User :Get :Group);
use Genpasswd;
use Mail::Sendmail;
# Import Date functions
use Date::Calc qw(:all);
=pod
This is the subroutine that invokes sendmail
=cut
sub Notify {
my $suspect = $_[0];
if ($notify{$suspect}{parameter} eq "\t") {
if (Failpass($suspect)) {
print "Failparm succeeded\n";
}
return 1;
}
if ($notify{$suspect}{unlocked}) {
if (Unlocked($suspect)) {
print "Unlocked succeeded\n";
}
}
if ($notify{$suspect}{locked}) {
if (Locked($suspect)) {
print "Locked succeeded\n";
}
}
if ($notify{$suspect}{enabled}) {
if (Enabled($suspect)) {
print "Enabled succeeded\n";
}
}
if ($notify{$suspect}{disabled}) {
if (Disabled($suspect)) {
print "Disabled succeeded\n";
}
}
my %mail;
$mail{Date} = $maintenant;
$mail{From} = $webmaster;
$mail{To} = "$$suspect{usrComment}";
$mail{Subject} = 'stuff';
$mail{Text} = "Hello,
I have done something.
Please let me know if you want something else.
Thanks!
TYBRIN Corporation
print "$mail{To}\n";
if ($$suspect{usrComment}) {
$sent = ((sendmail %mail) or die $Mail::Sendmail::error);
print "sendmail return value is $sent\n";
if ($sent) {
print "content of \$Mail::Sendmail::log:\n$Mail::Sendmail::log\n";
if ($Mail::Sendmail::error) {
print NOTIFICATIONS "content of \$Mail::Sendmail::error:\n$Mail::Sendmail::error\n";
}
else {
print NOTIFICATIONS "Sent password reset notice to $suspect of $$suspect{comment} at $mail{To}.\n";
$mpmaster{Text} .= "$suspect\'s password successfully reset, notice sent.\n";
}
}
}
else {
print NOTIFICATIONS "FAILED to send password reset notice to $suspect of $$suspect{comment} at $mail{To}.\n!!Error sending mail:\n$Mail::Sendmail::error\n ( $password )\n";
$mpmaster{Text} .= "$suspect\'s password reset to $password, but NO NOTICE WAS SENT. Please contact this user by other means.\n";
}
return;
}
#########################################################################################
yields:
#########################################################################################
Use of uninitialized value in length at C:/Perl/site/lib/Genpasswd.pm line 52, <CONFIGURATION> line 24.
[EMAIL PROTECTED]
retrying in 1 seconds...
connect to my-workstation-name.eglin.af.mil failed (Unknown error) no (more) retries!c
onnect to my-workstation-name.eglin.af.mil failed (Unknown error)
connect to my-workstation-name.eglin.af.mil failed
connect to my-workstation-name.eglin.af.mil failed (Unknown error) no (more) retries!
#########################################################################################
My perl -v says:
#########################################################################################
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
Built 21:33:05 Jun 17 2002
#########################################################################################
Any ideas?
--
Ed Ahlsen-Girard mailto:[EMAIL PROTECTED]
Network Administrator 850-882-6540x5349 ESC/ACU OL1
TYBRIN Corporation DSN:872-6540x5349 205 West D Ave (Bldg 350), Ste 628 LAN Integration FAX: 850-882-5594 Eglin AFB, FL 32542
http://www.tybrin.com http://www.eglin.af.mil/mission-planning
