Skip Menu |

This queue is for tickets about the MailTools CPAN distribution.

Report information
The Basics
Id: 1405
Status: resolved
Worked: 10 min
Priority: 0/
Queue: MailTools

People
Owner: MARKOV [...] cpan.org
Requestors: selsky [...] columbia.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Mail::Mailer::test is unix centric
Mail::Mailer::test is very unix-centric. This means when I try to run Mail::Mailer in test mode on a Windows box where /bin/sh and /bin/cat don't exist it doesn't work. Can we instead implement with print statements and such in perl? If this OK with you, I'll submit a patch which does this.
From: selsky [...] columbia.edu
I think this patch solves the problem. Another bug that this patch addresses is that when you use the "test" mailer, it looks for an executable called "test" instead of "echo" or "cat". I used an approach similar to the pipe subclass that Mail::Mailer::smtp uses. It seems to work on my unix machine. I can try it on my Win32 box tomorrow.
diff -ubr MailTools-1.47.orig/Mail/Mailer/test.pm MailTools-1.47/Mail/Mailer/test.pm --- MailTools-1.47.orig/Mail/Mailer/test.pm Fri Jul 5 06:03:09 2002 +++ MailTools-1.47/Mail/Mailer/test.pm Wed Aug 7 03:27:17 2002 @@ -7,7 +7,26 @@ sub exec { my($self, $exe, $args, $to) = @_; - exec('sh', '-c', 'echo "to: ' . join(" ",@{$to}) . '"; cat'); + print 'to: ' . join(' ',@{$to}) . "\n"; + untie(*$self) if tied *$self; + tie *$self, 'Mail::Mailer::test::pipe', $self; + $self; } + +sub close { 1 } + +package Mail::Mailer::test::pipe; + +sub TIEHANDLE { + my $pkg = shift; + my $self = shift; + return bless \$self; +} + +sub PRINT { + my $self = shift; + print @_; +} + 1; diff -ubr MailTools-1.47.orig/Mail/Mailer.pm MailTools-1.47/Mail/Mailer.pm --- MailTools-1.47.orig/Mail/Mailer.pm Fri Jul 5 06:03:09 2002 +++ MailTools-1.47/Mail/Mailer.pm Wed Aug 7 03:17:00 2002 @@ -149,7 +149,7 @@ 'smtp' => undef, 'qmail' => '/usr/sbin/qmail-inject;/var/qmail/bin/qmail-inject', - 'test' => 'test' + 'test' => undef ); # There are several flavours of mail, which do we have ????
From: selsky [...] columbia.edu
Patch is slightly more complete now. I updated the pod documentation in Mail/Mailer.pm
diff -ubr MailTools-1.47.orig/Mail/Mailer/test.pm MailTools-1.47/Mail/Mailer/test.pm --- MailTools-1.47.orig/Mail/Mailer/test.pm Fri Jul 5 06:03:09 2002 +++ MailTools-1.47/Mail/Mailer/test.pm Wed Aug 7 03:27:17 2002 @@ -7,7 +7,26 @@ sub exec { my($self, $exe, $args, $to) = @_; - exec('sh', '-c', 'echo "to: ' . join(" ",@{$to}) . '"; cat'); + print 'to: ' . join(' ',@{$to}) . "\n"; + untie(*$self) if tied *$self; + tie *$self, 'Mail::Mailer::test::pipe', $self; + $self; } + +sub close { 1 } + +package Mail::Mailer::test::pipe; + +sub TIEHANDLE { + my $pkg = shift; + my $self = shift; + return bless \$self; +} + +sub PRINT { + my $self = shift; + print @_; +} + 1; diff -ubr MailTools-1.47.orig/Mail/Mailer.pm MailTools-1.47/Mail/Mailer.pm --- MailTools-1.47.orig/Mail/Mailer.pm Fri Jul 5 06:03:09 2002 +++ MailTools-1.47/Mail/Mailer.pm Wed Aug 7 03:35:29 2002 @@ -57,8 +57,8 @@ =item C<test> -Used for debugging, this calls C</bin/echo> to display the data. No -mail is ever sent. C<$command> is ignored. +Used for debugging, this displays the data on STDOUT. No mail is ever +sent. C<$command> is ignored. =back @@ -149,7 +149,7 @@ 'smtp' => undef, 'qmail' => '/usr/sbin/qmail-inject;/var/qmail/bin/qmail-inject', - 'test' => 'test' + 'test' => undef ); # There are several flavours of mail, which do we have ????
[guest - Wed Aug 7 03:38:49 2002]: Show quoted text
> Patch is slightly more complete now. I updated the pod documentation > in Mail/Mailer.pm
I have included the patch unmodified. I think it is a useful addition to the module. The only small worry I have, is that the tie on the file-handle may not work for (very) old versions of Perl. MailTools runs in ancient code, which should not be broken. Testing, however, is on new code usually with newer releases of Perl. It is not a killer when it does not work, as long as Mail::Mailer::smtp keeps on working... Thanks for your contribution.