Perl模块 - MIME :: Lite :: TT :: HTML test.html.tt:未找到

时间:2015-09-30 18:18:32

标签: html perl

我正在尝试使用MIME :: Lite :: TT :: HTML发送邮件。

这是我的perl脚本。

#!/usr/bin/perl
use cPanelUserConfig;

 use strict;
 use warnings;
 use MIME::Lite::TT::HTML;

 my %params;

 $params{first_name} = 'Frank';
 $params{last_name}  = 'Wiles';
 $params{amt_due}    = '24.99';

 my %options;
 $options{INCLUDE_PATH} = '.';

 my $msg = MIME::Lite::TT::HTML->new(
            From        =>  'cs@pzr.com',
            To          =>  'xyz@gmail.com',
            Subject     =>  'Your new password',
            Template    => { html => 'test.html.tt' },
            TmplOptions =>  \%options,
            TmplParams  =>  \%params,
 );

 $msg->send;

我还在同一目录中创建了一个名为test.html.tt的文件。内容是:

     <html>
 <body>

 <strong>Hi [% first_name %]</strong>,

 <p>
 This is to confirm your purchase of $ [% amt_due %].
 </p>

 <p>
 Thank you!
 </p>
 </body>
 </html>

但是在执行脚本时我看到了这个错误:

[Wed Sep 30 11:09:06.557523 2015] [cgi:error] [pid 40187:tid 140571450533632] [client 123.136.217.67:49857] AH01215:文件错误 - test.html.tt:找不到:/ home //public_html/orders/cgi-bin/testmail.pl

如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您在与脚本相同的目录中创建了test.html.tt,但这不是您告诉TT要查看的目录。修正:

use FindBin qw( $RealBin );

$options{INCLUDE_PATH} = $RealBin;
相关问题