使用Perl发送电子邮件 [英] Sending email using Perl

查看:131
本文介绍了使用Perl发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Perl发送电子邮件。基本上我有一个Perl脚本打印出一个很好的格式的报告。我希望通过电子邮件发送该报告。我该怎么做?

I’m trying to use Perl to send an email message. Basically I have a Perl script that prints out a report in a nice format. I want that report to be sent via email. How can I do this?

推荐答案

MIME :: Lite 是许多用户使用的强大模块。它很容易使用,包括如果你想附加文件。

MIME::Lite is a strong module used by many. It's easy to use, including if you want to attach documents.

use MIME::Lite;
my $msg = MIME::Lite->new(
    From    => $from,
    To      => $to,
    Subject => $subject,
    Type    => 'text/plain',
    Data    => $message,
);
$msg->send;

由于默认使用 sendmail 反对SMTP),你甚至不需要配置它。

Since it uses sendmail by default (as opposed to SMTP), you don't even need to configure it.

这篇关于使用Perl发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆