解决方法

使用MIME::Lite CPAN模块

它可以用于将HTML电子邮件,图形文件电子邮件附件作为单部分或者多部分消息发送。

Perl如何发送电子邮件?

在UNIX / Linux中,使用perl脚本如何发送html电子邮件?

安装Perl MIME::Lite

使用以下命令进行安装

cpan -i MIME::Lite

Perl发送电子邮件脚本

#!/usr/bin/perl -w
use strict;
use MIME::Lite;

# SendTo email id
my $email = 'user@somewhere.com';

# create a new MIME Lite based email
my $msg = MIME::Lite->new
(
Subject => "HTML email test",
From    => 'YOU@somewhere.com',
To      => $email,
Type    => 'text/html',
Data    => '<H1>Hello</H1><br>This is a test email.
Please visit our site <a href="http://onitroad.local/">online</a><hr>'
);

$msg->send();

查看MIME::Lite帮助文档:

perldoc MIME::Lite
日期:2019-11-20 08:53:36 来源:oir作者:oir