} else {
- @{ $mail->{attachments} } = ($self->{tmpfile}) unless ($self->{do_not_attach});
+ if (!$self->{"do_not_attach"}) {
+ @{ $mail->{attachments} } =
+ ({ "filename" => $self->{"tmpfile"},
+ "name" => $self->{"attachment_filename"} ?
+ $self->{"attachment_filename"} : $self->{"tmpfile"} });
+ }
$mail->{message} =~ s/\r\n/\n/g;
$myconfig->{signature} =~ s/\\n/\n/g;
foreach my $attachment (@{ $self->{attachments} }) {
+ my $filename;
+
+ if (ref($attachment) eq "HASH") {
+ $filename = $attachment->{"name"};
+ $attachment = $attachment->{"filename"};
+ } else {
+ $filename = $attachment;
+ # strip path
+ $filename =~ s/(.*\/|$self->{fileid})//g;
+ }
+
my $application =
($attachment =~ /(^\w+$)|\.(html|text|txt|sql)$/)
? "text"
return "$attachment : $!";
}
- my $filename = $attachment;
-
- # strip path
- $filename =~ s/(.*\/|$self->{fileid})//g;
-
print OUT qq|--${boundary}
Content-Type: $application/$self->{format}; name="$filename"; charset="$self->{charset}"
Content-Transfer-Encoding: BASE64