Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Mail-Sender CPAN distribution.

Report information
The Basics
Id: 20722
Status: resolved
Priority: 0/
Queue: Mail-Sender

People
Owner: JENDA [...] cpan.org
Requestors: stephen [...] enterity.com
Cc:
AdminCc:

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



Subject: MailMsg destroys the passed-in argument hash
A construct like the following fails for all but the first recipient because the message body is destroyed by the first send: my $message_params = { from => $from, subject => $form->{name} || $form->{title}, msg => $message, }; foreach my $recipient( @recipients ) { $message_params->{to} = $recipient; $sender->MailMsg( $message_params ) or die "$recipient: ".$Mail::Sender::Error; } It is not clear to me whether other fields are likewise affected, but this seems to be unreasonable behavior as there is nothing I found in the documentation of MailMsg that suggested that the hashref I pass to the function would be altered. This was discovered under Perl 5.8.5 on Linux 2.6.9-22
From: krishnoid [...] wapacut.com
On Thu Jul 27 13:21:05 2006, HOWARS wrote: Show quoted text
> A construct like the following fails for all but the first recipient > because the message body is destroyed by the first send:
MailMsg() explicitly erases the message from the hash. My WAG is that it's done to discourage sending bulk mail via this module. Note the 'If you need to send only one mail' clause below also. =head2 MailMsg <blah blah blah> The module was made so that you could create an object initialized with all the necesary options and then send several messages without need to specify the SMTP server and others each time. If you need to send only one mail using MailMsg() or MailFile() you do not have to create a named object and then call the method. You may do it like this : <blah blah blah> =cut sub MailMsg { my $self = shift; my $msg; local $_; if (ref $_[0] eq 'HASH') { my $hash=$_[0]; $msg=$hash->{'msg'}; delete $hash->{'msg'} } else { $msg = pop; } <blah blah blah> }
Fixed. It was not intentional.