2012-08-06 5 views
2

Mail :: Sendmail cpan 모듈을 사용하여 전자 메일을 보내는 전자 메일을 보내는 간단한 테스트 스크립트가 있습니다. Strawberry Perl을 사용하는 Windows 컴퓨터에서 작동하고 명령 줄을 통해 모든 것이 잘된 것처럼 보입니다. 이 발생할 수있는 어떤 이유는Mail :: Sendmail을 사용하여 Windows 컴퓨터를 사용하여 perl 스크립트에서 전자 메일 보내기

use Mail::Sendmail qw(sendmail %mailcfg); 
$mailcfg{from} = '[email protected]'; 

print "Testing Mail::Sendmail version $Mail::Sendmail::VERSION\n"; 
print "Default server: $Mail::Sendmail::mailcfg{smtp}->[0]\n"; 
print "Default sender: $Mail::Sendmail::mailcfg{from}\n"; 

%mail = ( To  => '[email protected]', 
      From => '[email protected]', 
      Message => 'Test!' 

     ); 

sendmail(%mail) or die $Mail::Sendmail::error; 

print "OK. Log says:\n", $Mail::Sendmail::log; 

있습니까 : 나는 connect to localhost failed (No connection could be made because the target machine refused it.)

내 스크립트가 없다는 오류를 받고 있어요?

+0

SMTP 제출을 기록하려면 [Wireshark] (http://wireshark.org)와 같은 네트워크 스니퍼를 사용하십시오. 로그를 제공하십시오. – daxim

+0

'Mail :: Sendmail :: error'의 상태를 묻지 않습니까? – charlesbridge

+0

아. 내가 가지고있는 죽을 성명서는 나를 오도하고 있었다. 지금 내 질문에 대한 조정을 할 것입니다! –

답변

1

기본적으로 Mail :: Sendmail은 로컬 호스트로 메일을 보내도록 구성되어 있지만 SMTP 서버는 실행하지 않습니다.

적합한 서버를 구성해야합니다. 도움말을 참조하십시오.

Default SMTP server(s) 
     This is probably all you want to configure. It is usually done 
     through $mailcfg{smtp}, which you can edit at the top of the 
     Sendmail.pm file. This is a reference to a list of SMTP servers. 
     You can also set it from your script: 

     "unshift @{$Mail::Sendmail::mailcfg{'smtp'}} , 'my.mail.server';" 

     Alternatively, you can specify the server in the %mail hash you 
     send from your script, which will do the same thing: 

     "$mail{smtp} = 'my.mail.server';"