=encoding euc-jp
=head1 ̾Á°
Net::SMTP - SMTP(Simple Mail Transfer Protocol)¥¯¥é¥¤¥¢¥ó¥È
=head1 ³µÍ×
use Net::SMTP;
# ¥³¥ó¥¹¥È¥é¥¯¥¿
$smtp = Net::SMTP->new('mailhost');
$smtp = Net::SMTP->new('mailhost', Timeout => 60);
=head1 ÀâÌÀ
¤³¤Î¥â¥¸¥å¡¼¥ë¤ÏSMTP¤ª¤è¤ÓESMTP¤Ø¤Î¥¯¥é¥¤¥¢¥ó¥È¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò¼ÂÁõ¤·¡¢
Perl5¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬SMTP¥µ¡¼¥Ð¡¼¤ÈÄÌ¿®¤¹¤ë¤³¤È¤ò²Äǽ¤Ë¤·¤Þ¤¹¡£
¤³¤Î¥É¥¥å¥á¥ó¥È¤Ï¡¢ÆɼԤ¬RFC821¤Çµ½Ò¤µ¤ì¤Æ¤¤¤ëSMTP¥×¥í¥È¥³¥ë¤Î³µÇ°¤Ë
ÀºÄ̤·¤Æ¤¤¤ë¤â¤Î¤È¤·¤Þ¤¹¡£
¿·¤·¤¤Net::SMTP¥ª¥Ö¥¸¥§¥¯¥È¤ÏI¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æºî¤é¤ì¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
°ìÅÙºîÀ®¤¹¤ì¤Ð¡¢¤³¤Î¥ª¥Ö¥¸¥§¥¯¥È¤òÄ̤·¤Æ¤¹¤Ù¤Æ¤ÎSMTP¥³¥Þ¥ó¥É¤Ë¥¢¥¯¥»¥¹¤¹¤ë
¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
Net::SMTP¥¯¥é¥¹¤ÏNet::Cmd¤ÈIO::Socket::INET¤Î¥µ¥Ö¥¯¥é¥¹¤Ç¤¹¡£
=head1 »ÈÍÑÎã
¤³¤ÎÎã¤Ïmailhost¤È¤¤¤¦SMTP¥µ¡¼¥Ð¤Î¥á¡¼¥ë¡¦¥É¥á¥¤¥ó̾¤òɽ¼¨¤·¤Þ¤¹:
#!/usr/local/bin/perl -w
use Net::SMTP;
$smtp = Net::SMTP->new('mailhost');
print $smtp->domain,"\n";
$smtp->quit;
¤³¤ì¤Ïmailhost¤È¤¤¤¦Ì¾Á°¤ÎSMTP¥µ¡¼¥Ð¤Ë¤¢¤ëpostmaster¤Ë¾®¤µ¤Ê¥á¥Ã¥»¡¼¥¸¤ò
Á÷¿®¤·¤Þ¤¹:
#!/usr/local/bin/perl -w
use Net::SMTP;
$smtp = Net::SMTP->new('mailhost');
$smtp->mail($ENV{USER});
$smtp->to('postmaster');
$smtp->data();
$smtp->datasend("To: postmaster\n");
$smtp->datasend("\n");
$smtp->datasend("A simple test message\n");
$smtp->dataend();
$smtp->quit;
=head1 ¥³¥ó¥¹¥È¥é¥¯¥¿
=over 4
=item new Net::SMTP [ HOST, ] [ OPTIONS ]
¤³¤ì¤¬¿·¤·¤¤Net::SMTP¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥ó¥¹¥È¥é¥¯¥¿¤Ç¤¹¡£C¤Ï
SMTPÀܳ¤·¤è¤¦¤È¤¹¤ë¥ê¥â¡¼¥È¥Û¥¹¥È¤Î̾Á°¤Ç¤¹¡£
C¤¬»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢C<:config>¤Ç»ØÄꤵ¤ì¤¿
C¤¬»È¤ï¤ì¤Þ¤¹¡£
C¤Ï¥¡¼¤ÈÃͤÎÁȤȤ¤¤¦¥Ï¥Ã¥·¥å¤Î·Á¼°¤ÇÅϤµ¤ì¤Þ¤¹¡£
»ØÄê¤Ç¤¤ë¥ª¥×¥·¥ç¥ó¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¹:
B - SMTP¤Ï¤¢¤Ê¤¿¼«¿È¤Ç¤¢¤ë¤³¤È¤ò¼±Ê̤¹¤ë¤³¤È¤òɬÍפȤ·¤Þ¤¹¡£
¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¤¢¤Ê¤¿¤Î¥á¡¼¥ë¡¦¥É¥á¥¤¥ó¤È¤·¤ÆÅϤ¹Ê¸»úÎó¤ò»ØÄꤷ¤Þ¤¹¡£
Í¿¤¨¤é¤ì¤Ê¤±¤ì¤Ð²óÅú¤¬¼èÆÀ¤µ¤ì¤Þ¤¹¡£
B ¤È B - ¤³¤ì¤é¤Î¥Ñ¥é¥á¡¼¥¿¤Ï¡¢¥½¥±¥Ã¥È¤ò
¥í¡¼¥«¥ë¥Ý¡¼¥È¤Ë¥Ð¥¤¥ó¥É¤¹¤ë¤³¤È¤ò²Äǽ¤Ë¤¹¤ë¤¿¤áIO::Socket¤Ë
ľÀÜÅϤµ¤ì¤Þ¤¹¡£
B - SMTP¥µ¡¼¥Ð¡¼¤«¤é¤Î±þÅú¤òÂԤġ¢ÉÃñ°Ì¤Ç¤ÎºÇÂç»þ´Ö
(¥Ç¥Õ¥©¥ë¥È:120)
B - ¥Ç¥Ð¥Ã¥°¾ðÊó¤òÍøÍѤǤ¤ë¤è¤¦¤Ë¤·¤Þ¤¹
Îã:
$smtp = Net::SMTP->new('mailhost',
Hello => 'my.mail.domain'
Timeout => 30,
Debug => 1,
);
=back
=head1 ¥á¥½¥Ã¥É
Æä˵½Ò¤¬¤Ê¤±¤ì¤Ð¡¢Á´¤Æ¤Î¥á¥½¥Ã¥É¤ÏI¤Þ¤¿¤ÏI¤òÊÖ¤·¤Þ¤¹¡£
I¤¬½èÍý¤¬À®¸ù¤·¤¿¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£¥á¥½¥Ã¥É¤¬ÃͤòÊÖ¤¹¤È
Àë¸À¤·¤Æ¤¤¤ë¤È¤¤Ë¤Ï¡¢¼ºÇԤǤÏI¤Þ¤¿¤Ï¶õ¥ê¥¹¥È¤òÊÖ¤·¤Þ¤¹¡£
=over 4
=item banner ()
ºÇ½é¤ËÀܳ¤¬³ÎΩ¤µ¤ì¤¿¤È¤¡¢¥µ¡¼¥Ð¡¼¤¬¤Ä¤±¤Æ±þÅú¤¹¤ë¥Ð¥Ê¡¼¥á¥Ã¥»¡¼¥¸¤ò
ÊÖ¤·¤Þ¤¹¡£
=item domain ()
ÀܳÃæ¤Ë¥ê¥â¡¼¥ÈSMTP¥µ¡¼¥Ð¡¼¤¬¼«Ê¬¤Ç¼±Ê̤¹¤ë¥É¥á¥¤¥ó¤òÊÖ¤·¤Þ¤¹¡£
=item hello ( DOMAIN )
»ÈÍѤ·¤Æ¤¤¤ë¥á¡¼¥ë¡¦¥É¥á¥¤¥ó¤òEHLO¥³¥Þ¥ó¥É¡ÊEHLO¤¬¤À¤á¤Ê¾ì¹ç¤Ë¤ÏHELO¡Ë¤ò
»È¤Ã¤Æ¡¢¥ê¥â¡¼¥È¥µ¡¼¥Ð¡¼¤ËÅÁ¤¨¤Þ¤¹¡£¤³¤Î¥á¥½¥Ã¥É¤ÏNet::SMTP¥ª¥Ö¥¸¥§¥¯¥È¤¬
ºîÀ®¤µ¤ì¤¿»þÅÀ¤Ç¼«Æ°Åª¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¤Î¤Ç¡¢¥æ¡¼¥¶¤ÏÄ̾¤³¤ì¤ò¤¢¤¨¤Æ
¸Æ¤Ó½Ð¤¹É¬ÍפϤ¢¤ê¤Þ¤»¤ó¡£
=item etrn ( DOMAIN )
»ØÄꤵ¤ì¤¿DOMAIN¤Î¤¿¤á¤Î¥¥å¡¼¤Î¼Â¹Ô¤òÍ׵ᤷ¤Þ¤¹¡£
=item auth ( USERNAME, PASSWORD )
SASLǧ¾Ú¤ò»î¤ß¤Þ¤¹¡£
=item mail ( ADDRESS [, OPTIONS] )
=item send ( ADDRESS )
=item send_or_mail ( ADDRESS )
=item send_and_mail ( ADDRESS )
Âбþ¤¹¤ë¥³¥Þ¥ó¥É¤òMAIL¡¢SEND¡¢SOML¡¢SAML¥µ¡¼¥Ð¡¼¤ØÁ÷¿®¤·¤Þ¤¹¡£C¤Ï
Á÷¿®¸µ¤Î¥¢¥É¥ì¥¹¤Ç¤¹¡£ ¤³¤ì¤Ë¤è¤ê¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¿®¤ò³«»Ï¤·¤Þ¤¹¡£¥á¥Ã¥»¡¼¥¸¤ò
Á÷¿®¤¹¤ë³Æ¥¢¥É¥ì¥¹¤ËÂФ·¤ÆC¥á¥½¥Ã¥É¤¬¸Æ¤Ó½Ð¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
C¥á¥½¥Ã¥É¤ÏÄɲäÎESMTP¥ª¥×¥·¥ç¥ó¤ò¥¡¼¤ÈÃͤÎÁȤȤ¤¤¦¥Ï¥Ã¥·¥å·Á¼°¤Ç
ÅϤ¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ »ØÄê¤Ç¤¤ë¥ª¥×¥·¥ç¥ó¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¹:
Size =>
Return => ??>
Bits => "7" | "8"
Transaction =>
Envelope =>
=item reset ()
¥µ¡¼¥Ð¡¼¤Î¥¹¥Æ¡¼¥¿¥¹¤ò¥ê¥»¥Ã¥È¤·¤Þ¤¹¡£¤³¤ì¤Ï¥á¥Ã¥»¡¼¥¸¤¬¤¹¤Ç¤Ë³«»Ï¤µ¤ì¤Æ¤Ï
¤¤¤Æ¤â¥Ç¡¼¥¿¤Ï²¿¤âÁ÷¿®¤·¤Æ¤¤¤Ê¤¤¤È¤¡¢¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¿®¤ò¥¥ã¥ó¥»¥ë¤¹¤ë
¤È¤¤Ë¸Æ¤Ó½Ð¤¹¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
=item recipient ( ADDRESS [, ADDRESS [ ...]] [, OPTIONS ] )
¥µ¡¼¥Ð¡¼¤Ë¸½ºß¤Î¥á¥Ã¥»¡¼¥¸¤¬»ØÄꤵ¤ì¤¿¤¹¤Ù¤Æ¤Î¥¢¥É¥ì¥¹¤ËÁ÷¿®¤·¤Ê¤±¤ì¤Ð
¤Ê¤é¤Ê¤¤¤³¤È¤òÅÁ¤¨¤Þ¤¹¡£³Æ¥¢¥É¥ì¥¹¤Ï¥µ¡¼¥Ð¡¼¤Ø¤ÎÊ̤Υ³¥Þ¥ó¥É¤ÇÁ÷¿®¤µ¤ì¤Þ¤¹¡£
¤¤¤º¤ì¤«¤Î¥¢¥É¥ì¥¹¤Ø¤ÎÁ÷¿®¤¬¼ºÇÔ¤·¤¿¾ì¹ç¡¢½èÍý¤ÏÃæÃǤµ¤ìI¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£
¤â¤·¤½¤¦¤Ç¤¢¤ë¤³¤È¤ò˾¤à¤Î¤Ç¤¢¤ì¤Ð¡¢C¤«¤É¤¦¤«¤Ï¥æ¡¼¥¶¡¼¤Ë¤è¤ê¤Þ¤¹¡£
C¥á¥½¥Ã¥É¤Ï¡¢¥¡¼¤ÈÃͤÎÁȤò»È¤¦¥Ï¥Ã¥·¥å¤Î¤è¤¦¤Ê·Á¼°¤Ç
ÅϤµ¤ì¤ëÄɲäΥª¥×¥·¥ç¥ó¤ò¼õ¤±ÉÕ¤±¤Þ¤¹¡£²Äǽ¤Ê¥ª¥×¥·¥ç¥ó¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¹:
Notify =>
SkipBad => ÉÔÀµ¤Ê¥¢¥É¥ì¥¹¤ò̵»ë
C¤¬true¤Ç¤¢¤ì¤Ð¡¢C¤ÏÉÔÀµ¤Ê¥¢¥É¥ì¥¹¤Ë¤Ö¤Ä¤«¤Ã¤¿¤È¤
¥¨¥é¡¼¤òÊÖ¤µ¤º¡¢À®¸ù¤·¤¿¥¢¥É¥ì¥¹¤ÎÇÛÎó¤òÊÖ¤·¤Þ¤¹¡£
$smtp->recipient($recipient1,$recipient2); # Àµ¾ï
$smtp->recipient($recipient1,$recipient2, { SkipBad => 1 }); # Àµ¾ï
$smtp->recipient("$recipient,$recipient2"); # ÉÔÀµ
=item to ( ADDRESS [, ADDRESS [...]] )
=item cc ( ADDRESS [, ADDRESS [...]] )
=item bcc ( ADDRESS [, ADDRESS [...]] )
C¤ÎƱµÁ¸ì¡£
=item data ( [ DATA ] )
¸½ºß¤Î¥á¥Ã¥»¡¼¥¸¤«¤é¥Ç¡¼¥¿¤ÎÁ÷¿®¤ò³«»Ï¤·¤Þ¤¹¡£
C¤Ë¤Ï¥ê¥¹¥È¤Þ¤¿¤Ï¥ê¥¹¥È¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢C¤ÎÆâÍƤȺǸå¤Îʸ»ú C<".\r\n">¤¬¥µ¡¼¥Ð¡¼¤Ë
Á÷¿®¤µ¤ì¤Þ¤¹¡£¥Ç¡¼¥¿¤¬¼õ¤±¼è¤é¤ì¤ë¤È¡¢·ë²Ì¤Ïtrue¤Ë¤Ê¤ê¤Þ¤¹¡£
C¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¡¢·ë²Ì¤Ï¥µ¡¼¥Ð¡¼¤¬¥Ç¡¼¥¿¤¬Á÷¿®¤µ¤ì¤ë¤³¤È¤ò˾¤ó¤Ç
¤¤¤ë¤«¤É¤¦¤«¤Ë¤Ê¤ê¤Þ¤¹¡£¤½¤Î¤È¤¤Ë¤Ï¡¢¥Ç¡¼¥¿¤ÏL<:cmd>¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë
C¡¢C¥á¥½¥Ã¥É¤ò»È¤Ã¤ÆÁ÷¿®¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
=item expand ( ADDRESS )
¥µ¡¼¥Ð¡¼¤Ë»ØÄꤷ¤¿¥¢¥É¥ì¥¹¤ÎŸ³«¤ò°ÍÍꤷ¤Þ¤¹¡£¥µ¡¼¥Ð¡¼¤«¤éÆɤ߹þ¤Þ¤ì¤¿
¥Æ¥¥¹¥È¤¬Æþ¤Ã¤¿ÇÛÎó¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£
=item verify ( ADDRESS )
C¤¬¥á¡¼¥ë¡¦¥¢¥É¥ì¥¹¤È¤·¤ÆÀµ¤·¤¤¤«¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡£
=item help ( [ $subject ] )
¥µ¡¼¥Ð¡¼¤«¤é¥Ø¥ë¥×¡¦¥Æ¥¥¹¥È¤ò¼èÆÀ¤·¤Þ¤¹¡£ ¥Æ¥¥¹¥È¤¢¤ë¤¤¤Ï¼ºÇÔ¤·¤¿¤éundef¤òÊÖ¤·¤Þ¤¹¡£
=item quit ()
QUIT¥³¥Þ¥ó¥É¤ò¥ê¥â¡¼¥ÈSMTP¥µ¡¼¥Ð¡¼¤ËÁ÷¿®¤·¡¢¥½¥±¥Ã¥ÈÀܳ¤ò¥¯¥í¡¼¥º¤·¤Þ¤¹¡£
=back
=head1 ¥¢¥É¥ì¥¹
¥¢¥É¥ì¥¹¤ò¼õ¤±¼è¤ëÁ´¤Æ¥á¥½¥Ã¥É¤ÏŬÀÚ¤Êrfc2821¤Ë´ð¤Å¤¤¤¿¥¢¥É¥ì¥¹¤Ç¤¢¤ë¤³¤È¤ò
´üÂÔ¤·¤Þ¤¹¡£Net::SMTP¤Ï³Æ¥«¥Ã¥³(<>)¤Ç°Ï¤Þ¤ì¤¿¥¢¥É¥ì¥¹¤ò¼õ¤±ÉÕ¤±¤Þ¤¹¡£
funny user@domain ´Ö°ã¤¤
"funny user"@domain Àµ¤·¤¤, ¿ä¾©
<"funny user"@domain> OK
=head1 »²¹Í»ñÎÁ
L<:cmd>
=head1 ºî¼Ô
Graham Barr
=head1 Ãøºî¸¢(COPYRIGHT)
Copyright (c) 1995-1997 Graham Barr. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=for html
I<$Id: SMTP.pod,v 1.3 2011/01/27 13:15:11 iwai Exp $>