Skip Menu |

This queue is for tickets about the Net-SMTP-TLS CPAN distribution.

Report information
The Basics
Id: 33031
Status: open
Priority: 0/
Queue: Net-SMTP-TLS

People
Owner: Nobody in particular
Requestors: jdipaolo [...] rdpfoodservice.com
Cc:
AdminCc:

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



Subject: Bug in datasend
Date: Fri, 8 Feb 2008 14:25:38 -0500
To: bug-Net-SMTP-TLS [...] rt.cpan.org
From: Joseph DiPaolo <jdipaolo [...] rdpfoodservice.com>
If the SMTP server you are attempting to send to doesn't accept a large message in a single batch, your datasend method will just resend the first section of the message over and over until the proper size limit is reached. The fix is to increment $offset by $w for each iteration of the loop as such: # send stuff over raw (for use as message body) sub datasend { my $cmd = shift; my $arr = @_ == 1 && ref($_[0]) ? $_[0] : \@_; my $line = join("" ,@$arr); return 0 unless defined(fileno($cmd->{sock})); my $last_ch = $cmd->{last_ch}; $last_ch = $cmd->{last_ch} = "\012" unless defined $last_ch; return 1 unless length $line; $line =~ tr/\r\n/\015\012/ unless "\r" eq "\015"; my $first_ch = ''; if ($last_ch eq "\015") { $first_ch = "\012" if $line =~ s/^\012//; } elsif ($last_ch eq "\012") { $first_ch = "." if $line =~ /^\./; } $line =~ s/\015?\012(\.?)/\015\012$1$1/sg; substr($line,0,0) = $first_ch; $cmd->{last_ch} = substr($line,-1,1); my $len = length($line); my $offset = 0; my $win = ""; vec($win,fileno($cmd->{sock}),1) = 1; my $timeout = $cmd->{sock}->timeout || undef; local $SIG{PIPE} = 'IGNORE' unless $^O eq 'MacOS'; print "Printing arr\n"; print $line."\n"; print "Done Printing arr\n"; while($len) { my $wout; if (select(undef,$wout=$win, undef, $timeout) > 0 or -f $cmd- Show quoted text
>{sock}) # -f for testing on win32
{ my $w = syswrite($cmd->{sock}, $line, $len, $offset); unless (defined($w)) { carp("Error: $!"); return undef; } $len -= $w; $offset += $w; #BUG FIX; } else { carp("Error: Timeout"); return undef; } } } --------------------------------------------------- Joseph DiPaolo I.T. Manager RDP Foodservice jdipaolo@rdpfoodservice.com
I have also hit this bug. Attached is a patch which does as the original reporter suggested, and I can confirm works. Patch the latest version on CPAN (0.12) with this patch and it should resolve this bug.
--- Net/SMTP/TLS.pm.orig 2009-03-26 18:39:18.000000000 +0000 +++ Net/SMTP/TLS.pm 2009-03-26 18:43:37.000000000 +0000 @@ -367,6 +367,7 @@ sub datasend { return undef; } $len -= $w; + $offset += $w; } else {