[Techtalk] perl mail script troubles :o(

Nicole Zimmerman colby at wsu.edu
Wed Jan 2 19:14:19 EST 2002


I am having irritating problems with a mail script I wrote in perl. It
works great on a debian testing/unstable box but doesn't do what it should
on a debian stable box.

The script uses Mail::Mailer and connects to a SMTP server to send a
message (a MIME message, empty text with 2 attachments). 

On the debian testing box I have:

libmailtools-perl 1.42-1
perl 5.6.1-6
libmime-base64-perl 2.12-4

On the debian stable box I have:

mailtools 1.13-4
perl-5.005 5.005.03-7.1
libmime-base64-perl 2.11-2

On the testing box, the mail is successfully sent. On the stable box, the
mail appears to send from the script (as in the script completes with no
errors), but the mail never arrives.  I have tried this script on 2 or 3
debian stable boxes with different external and internal SMTP servers and
it doesn't ever seem to work. It doesn't work if I reconfigure exim to
route mail and try using it either.

I have tried using the same SMTP server as the domain the mail is going to
(e.g. @wsu.edu routes through SMTP server mail.wsu.edu) and using the
local mail server (e.g. sending to @wsu.edu through SMTP server
mail.mydomain.com) with the same results. We are, however, able to send
mail through the box using Mozilla and an SMTP server... this same SMTP
server/address combination doesn't work with the script. I have also tried
using IP addresses instead of 'names', but that doesn't help either.

The important parts of the script:

------
#!/usr/bin/perl

use Mail::Mailer;
use Date::Format;
use MIME::Base64;

# who to send mail to  
my $msg_to = "colby\@domain.com";

# message subject
my $msg_subj = "some nice subject";

# SMTP server -- if you don't need to use one, leave this empty!
my $smtp_server = "mail.domain.com";

my $msg;

if($smtp_server ne "")
{
   $msg = new Mail::Mailer 'smtp', Server => $smtp_server;
}
else
{
   $msg = new Mail::Mailer 'sendmail';
}

my $mime_type = "application/x-gzip";
my $boundary = "blah";

my %headers = ('From' => 'somebody at somewhere.com',
               'To' => $msg_to,
               'Subject' => $msg_subj,
               'MIME-Version' => '1.0',
               'Content-Type' => 'multipart/mixed; boundary="' . $boundary . '"');

$msg->open(\%headers);

print $msg "This is a happy little MIME message!\n";
print $msg "--$boundary\n";

<more print $msg that glues the message together>

$msg->close;

----

If anyone could provide insight I would greatly appreciate it. The boxes
cannot be upgraded to debian testing (they are a thin secure install on
purpose). I am not so sure that upgrading perl, mailtools, and
libmime-base64 to the testing versions will fix the problem.

Also, if someone could suggest another way of going about solving the same
problem (sending a MIME message through an SMTP server NOT relying on
sendmail on the local box) with perl, I am willing to give it a look. It
is a better option than having someone go to an offsite location and carry
data off by firing up Mozilla and attaching stuff.

-nicole




More information about the Techtalk mailing list