Revision 8fec2dc1
Von Moritz Bunkus vor mehr als 8 Jahren hinzugefügt
SL/Mailer.pm | ||
---|---|---|
121 | 121 |
sub _create_attachment_part { |
122 | 122 |
my ($self, $attachment) = @_; |
123 | 123 |
|
124 |
my $source_file_name; |
|
125 |
|
|
126 | 124 |
my %attributes = ( |
127 | 125 |
disposition => 'attachment', |
128 | 126 |
encoding => 'base64', |
129 | 127 |
); |
130 | 128 |
|
129 |
my $attachment_content; |
|
130 |
|
|
131 | 131 |
if (ref($attachment) eq "HASH") { |
132 | 132 |
$attributes{filename} = $attachment->{name}; |
133 |
$source_file_name = $attachment->{filename};
|
|
133 |
$attachment_content = $attachment->{content} // eval { read_file($attachment->{filename}) };
|
|
134 | 134 |
|
135 | 135 |
} else { |
136 | 136 |
# strip path |
137 | 137 |
$attributes{filename} = $attachment; |
138 | 138 |
$attributes{filename} =~ s:.*\Q$self->{fileid}\E:: if $self->{fileid}; |
139 | 139 |
$attributes{filename} =~ s:.*/::g; |
140 |
$source_file_name = $attachment;
|
|
140 |
$attachment_content = eval { read_file($attachment) };
|
|
141 | 141 |
} |
142 | 142 |
|
143 |
my $attachment_content = eval { read_file($source_file_name) }; |
|
144 | 143 |
return undef if !defined $attachment_content; |
145 | 144 |
|
146 | 145 |
my $application = ($attachment =~ /(^\w+$)|\.(html|text|txt|sql)$/) ? 'text' : 'application'; |
Auch abrufbar als: Unified diff
SL::Mailer: Inhalt von Attachments direkt übergeben können
Bisher wurde ein Attachmentinhalt immer aus einer Datei gelesen. Liegt der
Inhalt schon in einer Variable vor, so kann diese nun im Attachment-Hash
als Key »content« übergeben werden. Der Dateiname (Key »filename«) wird
dann ignoriert.