Macos 通过perl脚本从Mac OS X发送电子邮件

Macos 通过perl脚本从Mac OS X发送电子邮件,macos,perl,Macos,Perl,我正试图从我的Mac上使用Perl脚本发送电子邮件,我已经安装了该脚本 MIME::Lite模块。我正在使用一个基本脚本来测试: #!/usr/bin/perl use MIME::Lite; $msg = MIME::Lite->new( From =>"abc\@gmail.com", To =>"xyz\@gmail.com", Subject

我正试图从我的Mac上使用Perl脚本发送电子邮件,我已经安装了该脚本 MIME::Lite模块。我正在使用一个基本脚本来测试:

#!/usr/bin/perl

use MIME::Lite;

$msg = MIME::Lite->new(
                 From     =>"abc\@gmail.com",
                 To       =>"xyz\@gmail.com",
                 Subject  =>"Demo",
                 Data     =>"Sent :-):-)"
                 );
$msg->send();
我已经在macbook中设置了我的电子邮件帐户。
如果我无法发送电子邮件,需要检查其他内容,请指导我。

您可以使用系统调用命令行的日子一去不复返了:

mail boss@megacorp.net -s "I QUIT!" < body_of_message.txt

我没有使用过这个模块,但我注意到它的文档中说

MIME::Lite当前的维护人员不推荐使用它。有一个 备选方案的数量,如电子邮件::MIME或MIME::实体和 电子邮件::发件人,您可能应该使用它。MIME::Lite 继续累积奇怪的bug报告,并且没有收到大量的错误报告 由于提供了更好的替代方案,因此需要进行大量重构。 请考虑使用别的东西。

话虽如此,您可能需要执行以下操作

指定默认发送方法:

 MIME::Lite->send('smtp','some.host',Debug=>0);
 MIME::Lite->send('smtp','some.host', AuthUser=>$user, AuthPass=>$pass);

添加身份验证如果您希望通过电子邮件提供商发送邮件,请参阅模块文档
system("/path/to/mutt", "-s", "I QUIT", "boss\@megacorp.net", ...)
   or die "Could not send Email";
 MIME::Lite->send('smtp','some.host',Debug=>0);
 MIME::Lite->send('smtp','some.host', AuthUser=>$user, AuthPass=>$pass);