Subject: | Bug report: addresses in envelope_to are lost |
Date: | Wed, 23 Nov 2011 14:28:00 +0800 |
To: | bug-Mail-SendVarious [...] rt.cpan.org |
From: | Allan Dyer <adyer [...] yuikee.com.hk> |
Mail-SendVarious-0.3
perl, v5.10.1
Linux bluewhale 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC 2011 i686 GNU/Linux
I experienced this problem when using the sendmail() function, setting an address in envelope_to
results in mail being sent to the invalid address 1, use two addresses, and the address 2 is used. A
list is being used in a scalar context.
This is my code to demonstrate the problem:
#!/usr/bin/perl
#
# Show bug in Mail::SendVarious
use strict;
use warnings;
use Mail::SendVarious qw(make_message);
use vars qw($from $message @envelope_to);
($from, $message, @envelope_to) = make_message(
from => 'user@host',
envelope_to => 'user@host, user@host',
body => 'body stuff'
);
print "Using envelope_to:\n", join("\n", @envelope_to), "\n";
($from, $message, @envelope_to) = make_message(
from => 'user@host',
to => 'user@host, user@host',
body => 'body stuff'
);
print "Using to:\n", join("\n", @envelope_to), "\n";
-----
Output:
Using envelope_to:
2
Using to:
user@host
user@host
-----
Fix: I looked at SendVarious.pm and noted || being used where it would give scalar context to an
array during assignment. Splitting the assignment to two lines avoids the problem. diff output
89c89,90
< my @to = splitto($options{envelope_to}) || (splitto($options{to}), splitto($options{cc}));
---
Show quoted text
> my @to = splitto($options{envelope_to});
> @to = (splitto($options{to}), splitto($options{cc})) unless @to;
Regards
Allan Dyer