我一直在摸索着如何从Windows 7上的Perl发送电子邮件。我无法安装任何Perl模块,主动Perl安装。 (这意味着Mime :: Lite,Email :: Sender和Mail :: Sendmail都不在表格中)在Windows 7上使用Perl发送电子邮件,无需安装模块
我能找到的唯一电子邮件发送模块似乎是Net :: SMTP,但我一直无法弄清楚如何正确使用它。我不太了解SMTP服务器的功能,更不用说它们是如何工作的。我发现发送邮件的每一篇文章都建议使用我不具备的不同模块。
我看到another post建议使用Net :: SMTP :: SSL连接到Gmail,但我没有SSL模块。
这是一些代码,我到目前为止,我试图使用Gmail作为我的SMTP服务器:
use Net::SMTP;
$smtp = Net::SMTP->new('smtp.gmail.com'); # connect to an SMTP server
$smtp->mail('[email protected]'); # use the sender's address here
$smtp->to('[email protected]'); # recipient's address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: toAddress\@test.com\n");
$smtp->datasend("From: myAddress\@gmail.com\n");
$smtp->datasend("Subject: Test email\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("Hello, World!\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
我不断收到错误:
Can't call method 'mail' on an undefined value
这我假设手段它无法连接到SMTP服务器。我怎样才能解决这个问题?
也有任何其他模块标准与活动Perl更容易使用?
我真的在寻找类似于Linux SENDMAIL命令的东西,它非常简单,甚至不需要你连接或认证任何东西。 Linux SENDMAIL命令似乎甚至允许你组成你想要的任何“from”地址,这可能是非常危险但很棒!
编辑
而且它不是我去通过Gmail的要求。这只是我想到的第一件事。
我知道我应该使用'strict'和'warnings',但是这仅仅是一个快速脚本来尝试并获得它的工作。我尽可能保持它尽可能接近文档中的示例。 – tjwrona1992 2015-02-05 16:48:44
请参阅http://stackoverflow.com/q/11009844/176646 – ThisSuitIsBlackNot 2015-02-05 16:50:11
这实际上是我为我的链接而发布的帖子,我必须将它与另一个混合起来,我现在将修复该链接。正如你可以看到的那样,这篇文章建议使用'Net :: SMTP :: SSL',这是我没有的。我只有'NET :: SMTP'。 – tjwrona1992 2015-02-05 17:10:51