Set up MIME::Lite on Windows 7 without Outlook

ぃ、小莉子 提交于 2020-01-06 07:10:44

问题


I run ActiveState's ActivePerl on my Windows 7 box. I just installed the MIME::Lite module using the PPM (Perl Package Manager). The installation went fine.

However, as I try to run a very simple script

use strict;
use MIME::Lite;

my $msg = MIME::Lite->new(
        From     => 'myname@host.com',
        To       => 'myname@host.com',
        Subject  => "Mail Test",
        Data     => "Test Test!!",
    );
$msg->send;

I got this error:

SMTP Failed to connect to mail server: at C:\...\mail_test.pl line 10

Does that mean I need to install a 3rd party mail server on my windows? Or can I configure the script and/or windows to make it work without new installation? In particular, I do not run outlook on that machine. Thx!


回答1:


You need to give it a host to send the mail through, otherwise its going to try and use the SMTP server on your computer which A) you don't have and B) if its a home computer many would reject it as spam anyway.

The MIME::Lite documentation shows how to tell it what SMTP host to use. Set it up with the same host, username and password as you would your normal mail client.

Unfortunately, MIME::Lite doesn't support encryption so your mail will be going out insecure and in the clear. Some mail servers won't even talk unencrypted any more. Email::Sender I believe is what the email folks recommend you use these days.



来源:https://stackoverflow.com/questions/3680200/set-up-mimelite-on-windows-7-without-outlook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!