我正在尝试发送有关哈希值的 html 电子邮件(报告)。但我无法以表格格式打印哈希值。我HTML::Mason
用来执行我的 perl 命令(通过哈希循环)并在报告末尾打印它。但是我的 perl 代码没有被执行。
use HTML::Entities;
use Mail::Sendmail;
use MIME::Lite;
use Term::ANSIColor;
use Time::localtime;
use HTML::Mason;
my $ti = localtime;
my ( $day, $month, $year ) = ( $ti->mday, $ti->fullmonth, $ti->year );
# DEFINE A HASH
%coins = ( "Quarter" => 25, "Dime" => 10, "Nickel" => 5 );
$html = <<END_HTML;
Please direct any questions to <a href="mailto:abc@mydomain.com">MyEmailID</a><br><br>
<table border='1'>
<th>Keys</th><th>Values</th>
% while (($key, $value) = each(%coins)){
<TR>
<TD><% $key %></TD>
<TD><% $value %></TD>
</TR>
% }
</table>;
END_HTML
$msg = MIME::Lite->new(
from => 'abc@mydomain.com',
To => 'def@mydomain.com',
Subject => 'Report',
Type => 'multipart/related'
);
$msg->attach(
Type => 'text/html',
Data => qq{
<body>
<html>$html</html>
</body>
},
);
MIME::Lite->send( 'smtp', 'xxxs.xxxx.xxxxx.com' );
$msg->send;