如何在我从Perl CGI脚本发送的HTML电子邮件中包含CSS文件?

4 html css email perl cgi

我使用以下代码通过CGI perl创建和发送电子邮件.图像得到正确附加,但css文件没有.

  my $msg = new MIME::Lite(
            From    => $from,
            To      => $to_list,
            Subject => "My subject",
            Type    => 'text/html',  # 'multipart/mixed'
            Data    => $body
           );
 $msg->attach(Type => 'multipart/mixed',      Path => $DOCS_URL . "/fonts-min.css");
 $msg->attach(Type => 'multipart/mixed',      Path => $DOCS_URL . "/eat.css");
 $msg->attach(Type => 'multipart/mixed',      Path => $DOCS_URL . "/site_styles2.css");
 $msg->attach(Type => 'multipart/mixed',      Path => $DOCS_URL . "/calendar_layout.css");
 $msg->attach(Type => 'multipart/mixed',      Path => $DOCS_URL . "/errnacc.css");
 $msg->attach(Type => 'image/png',    Path => $DOCS_URL . "/separator.gif");
 $msg->attach(Type => 'image/png',    Path => $DOCS_URL . "/trans_pixel.gif");
 $msg->attach(Type => 'image/png',    Path => $DOCS_URL . "/itg_side.gif");

 $msg->send();
Run Code Online (Sandbox Code Playgroud)

图像正确附加,但css文件根本没有附加.知道什么'Type'应该用于附加CSS文件?还是有其他问题吗?

小智 7

我相信text/css应该没问题


ndp*_*ndp 6

从我的测试中,许多电子邮件客户端只需删除所有头元素,然后再显示电子邮件.因此,如果您必须支持各种电子邮件客户端,则使用外部样式表是不可行的.

我的建议是将样式直接包含在HTML中,就像那样痛苦.