Subject: | headers_from_message broken? |
Distribution name and version: Mail-Bulkmail-3.12.tar.gz
Perl version: v5.8.1
OS: mandrakelinux 9.2
Mail server: postfix-2.0.13-3mdk
Summary: the header_from_message setting appears not to work correctly.
Repro:
1. run the following program:
use Mail::Bulkmail "/var/www/ez/bulkmail_test/bm2.conf";
my @l = ('david.heath@oneworld.net', 'david@davidheath.org', 'davidheath@iname.com');
my $bulk = Mail::Bulkmail->new(
'From' => 'david.heath@oneworld.net',
'headers_from_message' =>1,
'Message' => 'From: david.heath@oneworld.net
To: list@oneworld.net
Subject: test
test message',
"LIST" => \@l
) || die Mail::Bulkmail->error();
$bulk->bulkmail() || die $bulk->error;
ACTUAL RESULT:
[heathd@vau19 bulkmail_test]$ perl bm_test.pl
Use of uninitialized value in substitution (s///) at /usr/lib/perl5/site_perl/5.8.1/Mail/Bulkmail.pm line 1781, <HANDLE1> line 14.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.1/Mail/Bulkmail.pm line 2210, <HANDLE1> line 14.
Use of uninitialized value in substitution (s///) at /usr/lib/perl5/site_perl/5.8.1/Mail/Bulkmail.pm line 1781, <HANDLE1> line 19.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.1/Mail/Bulkmail.pm line 2210, <HANDLE1> line 19.
EXPECTED RESULT:
no errors. Program should send emails correctly.
NOTES:
patch attached which fixes this. However I am not sure I have correctly understood your program, and also I am not a very experienced perl coder, so please check.
Basically, it seems that the program tries to cache headers parsed out from the supplied Message. However, it clears these cached headers but then fails to regenerate them.
The intention of my patch is to change the behaviour so that the cached headers are only cleared if they need to be regenerated.
Best regards
David Heath
--- Mail-Bulkmail-3.12/Bulkmail.pm 2003-12-22 18:54:10.000000000 +0000
+++ Mail/Bulkmail.pm 2004-11-15 19:00:14.000000000 +0000
@@ -485,18 +485,18 @@
};
};
- #first, wipe out any previously set headers_from_message
- if (defined $self->_previous_headers_from_message) {
- foreach my $header (@{$self->_previous_headers_from_message}){
- $self->header($header, undef);
+ #then, if we're setting new headers, we should set them.
+ if ($self->headers_from_message && ! $self->_extracted_headers_from_message) {
+ #first, wipe out any previously set headers_from_message
+ if (defined $self->_previous_headers_from_message) {
+ foreach my $header (@{$self->_previous_headers_from_message}){
+ $self->header($header, undef);
+ };
};
- };
- #wipe out the list of previously set headers
- $self->_previous_headers_from_message([]);
+ #wipe out the list of previously set headers
+ $self->_previous_headers_from_message([]);
- #then, if we're setting new headers, we should set them.
- if ($self->headers_from_message && ! $self->_extracted_headers_from_message) {
$self->_extracted_headers_from_message(1);
$passed[0] ||= $self->_Message(); #We'll sometimes call this method after setting the message
#sendmail-ify our messages newlines