【问题标题】:Perl MIME::Lite bad file descriptorPerl MIME::Lite 错误文件描述符
【发布时间】:2015-09-25 03:56:48
【问题描述】:

这是我目前的代码:

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

my $to = 'example@asd.com';
my $from = 'example@asd.com';
my $subject = 'Test Email';
my $message = 'This is test email sent by Perl Script';

my $msg = MIME::Lite->new(
             From     => $from,
             To       => $to,
             Subject  => $subject,
             Data     => $message
             );

$msg->add( "Type" => "multipart/mixed" );        
$msg->send("smtp", "good.domain.net");
print "Email Sent Successfully\n";

当我想运行脚本时出现以下错误:

无法连接到邮件服务器:...\email.pl 处的文件描述符错误 第 17 行。

我不知道问题可能是什么。有人知道如何解决这个问题吗?

编辑:我更正了上面的代码,它正在使用正确的服务器(它根本不需要身份验证)。

【问题讨论】:

  • 修复 perl 代码的第一步:use strict;use warnings;。这可能无法解决您的问题,但至少在寻求帮助时表现出一点意愿。
  • 从文档中,尚不清楚附加参数是否适用于实例方法。尝试先使用类方法设置用户名/密码,然后使用实例方法实际发送消息。
  • 感谢您的提示。如果我无法修复当前版本,我会尝试其他模块。

标签: perl email smtp send file-descriptor


【解决方案1】:

MIME::Lite SMTP 调试程序

尝试缩小搜索范围以找到您的问题。

1: telnet SMTP 主机时是否收到 SMTP 问候消息?
telnet mail.domain.net 25

1:YES => 向 MIME::Lite 发送(通过 SMTP)调用添加调试选项。

$msg->send("smtp", "mail.domain.net", Debug=>1, AuthUser=>'myname@domain.com', AuthPass=>"password" );

【讨论】:

  • 我认为25端口被阻塞了,因为我可以ping服务器,但是telnet命令连接失败。我将尝试修复连接(检查防火墙等)。无论如何,感谢您的建议,调试选项似乎很有用。
  • 我很笨,我试图连接到错误的服务器。 -,- 我找到了正确的服务器,它现在可以工作了。干杯。
猜你喜欢
  • 1970-01-01
  • 2016-01-04
  • 2014-03-14
  • 2013-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-08
相关资源
最近更新 更多