[ic] Email tag crash while sending two attachments
Gert van der Spoel
gert at 3edge.com
Fri Nov 12 21:07:47 UTC 2010
> Dear All,
>
> I am trying to send an email with two attachments using the email tag.
> Unfortunately it results in a Internal Server Error.
>
>
> [email
> to="Ton Verhagen <tverhagen at alamerce.nl>"
> from="Foobar <foobar at example.com>"
> subject="Email with an attachment"
> attach.0="images/test1.png"
> attach.1="images/test2.png"
>
> ]This email has two attachments.[/email]
>
>
> Error.log
> Runtime error: Can't use string ("images/test1.png") as a HASH ref while
> "strict refs" in use at (tag 'email') line 119.
>
> Am I missing something?
Hi Ton,
Below a patch that works for me. This is a patch against the latest
email.tag available in git, but if you look for the line 'if(! Ref($att) )
in your version it should also work with that.
I tested 3, 2, 1 and no attachments and all seems to work well ...
attach.0
attach.1
actually creates a array ref and not a hash ref from the looks of it.
Perhaps racke can do a 'second opinion' on below patch and improve it .. My
Perl is getting increasingly rusty these days :)
Use at own risk etc bla bla bla.
CU,
Gert
diff --git a/code/UserTag/email.tag b/code/UserTag/email.tag
index 97b3e9a..11f0889 100644
--- a/code/UserTag/email.tag
+++ b/code/UserTag/email.tag
@@ -139,15 +139,20 @@ sub {
Format => $opt->{body_format} ||
$att1_format,
);
+ my $tmpatt = [];
if(! ref($att) ) {
my $fn = $att;
- $att = [ { path => $fn } ];
+ $tmpatt = [ { path => $fn } ];
}
- elsif(ref($att) eq 'HASH') {
- $att = [ $att ];
+ elsif(ref($att) eq 'ARRAY') {
+ my @tmpattarr;
+ foreach my $attachment (@$att) {
+ push(@tmpattarr, { path => $attachment });
+ }
+ $tmpatt = \@tmpattarr;
}
More information about the interchange-users
mailing list