fixed the MIME type in 'emailreports.pm' to honor the 'image_format' option. #174

This commit is contained in:
Jordi Sanfeliu 2017-01-18 10:52:49 +01:00
parent b3b85b774e
commit 2e4349505f
2 changed files with 10 additions and 2 deletions

View File

@ -36,6 +36,7 @@ sub emailreports_send {
my $base_cgi = $config->{base_cgi};
my $imgs_dir = $config->{imgs_dir};
my $images;
my $mime;
logger("$myself: sending $report reports.");
@ -48,6 +49,9 @@ sub emailreports_send {
my $prefix = "$scheme://$userinfo$hostname:$port";
$mime = "image/png";
$mime = "image/svg+xml" if uc($config->{image_format}) eq "SVG";
my $html = <<"EOF";
<html>
<body bgcolor='FFFFFF' vlink='#888888' link='#888888'>
@ -195,7 +199,7 @@ EOF
);
while (my ($key, $val) = each(%{$images})) {
$msg->attach(
Type => 'image/png',
Type => $mime,
Id => $key,
Data => $val,
);

View File

@ -320,6 +320,7 @@ sub traffacct_sendreports {
my (undef, undef, undef, undef, $prev_month, $prev_year) = localtime(time - 3600);
my $n;
my $mime;
my $usage_dir = $config->{base_lib} . $config->{usage_dir};
my $report_dir = $config->{base_lib} . $config->{report_dir};
@ -327,6 +328,9 @@ sub traffacct_sendreports {
my $base_cgi = $config->{base_cgi};
my $imgs_dir = $config->{imgs_dir};
$mime = "image/png";
$mime = "image/svg+xml" if uc($config->{image_format}) eq "SVG";
logger("Sending monthly network traffic reports.");
my @tal = split(',', $traffacct->{list});
@ -398,7 +402,7 @@ sub traffacct_sendreports {
Path => $config->{base_dir} . $config->{logo_bottom},
);
$msg->attach(
Type => 'image/png',
Type => $mime,
Id => 'image_02',
Data => $image->content,
);