mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
206 lines
6.8 KiB
Text
206 lines
6.8 KiB
Text
|
=begin
|
|||
|
|
|||
|
= net/smtp.rb
|
|||
|
|
|||
|
== <20><><EFBFBD>Υ饤<CEA5>֥<EFBFBD><D6A5><EFBFBD><EFBFBD>ˤĤ<CBA4><C4A4><EFBFBD>
|
|||
|
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뤿<EFBFBD><EFBFBD><EFBFBD>Υץ<EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD> SMTP (Simple Mail Transfer Protocol)
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>饤<EFBFBD>֥<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>إå<EFBFBD><EFBFBD>ʤɥ<EFBFBD><EFBFBD><EFBFBD>Υǡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȤϤǤ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
SMTP <20>μ<EFBFBD><CEBC><EFBFBD><EFBFBD><EFBFBD> RFC2821 <20>˴𤤤Ƥ<F0A4A4A4><C6A4>ޤ<EFBFBD><DEA4><EFBFBD>
|
|||
|
|
|||
|
* RFC2821 ((<URL:http://www.ietf.org/rfc/rfc2821.txt>))
|
|||
|
|
|||
|
== <20><EFBFBD><E1A1BC><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>ˤĤ<CBA4><C4A4><EFBFBD>
|
|||
|
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>Υ饤<EFBFBD>֥<EFBFBD><EFBFBD>꤬<EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBF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
|||
|
* RAA ((<URL:http://www.ruby-lang.org/en/raa.html>))
|
|||
|
* RFC2822 ((<URL:http://www.ietf.org/rfc/rfc2822.txt>))
|
|||
|
|
|||
|
== <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
=== <20>Ȥˤ<C8A4><CBA4><EFBFBD><EFBFBD><EFBFBD><E1A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
SMTP <20><><EFBFBD>Ȥäƥ<C6A5><E1A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤϤޤ<CFA4> SMTP.start <20>ǥ<EFBFBD><C7A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2B3ABA4>ޤ<EFBFBD><DEA4><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ФΥ<EFBFBD><EFBFBD>ɥ쥹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD>֥<EFBFBD><EFBFBD>å<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD> File.open <20><>Ʊ<EFBFBD><C6B1><EFBFBD>褦<EFBFBD>˽<EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ưŪ<C6B0>ˤ<EFBFBD><CBA4>äƤ<C3A4><C6A4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD>ΤǤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
require 'net/smtp'
|
|||
|
Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp|
|
|||
|
# use smtp object only in this block
|
|||
|
}
|
|||
|
|
|||
|
your.smtp.server <20><>Ŭ<EFBFBD>ڤ<EFBFBD> SMTP <20><><EFBFBD><EFBFBD><EFBFBD>ФΥ<D0A4><CEA5>ɥ쥹<C9A5><ECA5B9><EFBFBD>ɤߤ<C9A4><DFA4><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD>̾<EFBFBD><EFBFBD><EFBFBD> LAN <20>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4>ץ<EFBFBD><D7A5>Х<EFBFBD><D0A5><EFBFBD><EFBFBD><EFBFBD> SMTP <20><><EFBFBD><EFBFBD><EFBFBD>Ф<EFBFBD><D0A4>Ѱդ<D1B0><D5A4>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>Ϥ<EFBFBD><CFA4>Ǥ<EFBFBD><C7A4><EFBFBD>
|
|||
|
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>å<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>餢<EFBFBD>Ȥ<EFBFBD> send_mail <20>ǥ<C7A5><E1A1BC><EFBFBD><EFBFBD>ή<EFBFBD><CEAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>
|
|||
|
|
|||
|
require 'net/smtp'
|
|||
|
|
|||
|
Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp|
|
|||
|
smtp.send_mail <<EndOfMail, 'your@mail.address', 'to@some.domain'
|
|||
|
From: Your Name <your@mail.address>
|
|||
|
To: Dest Address <to@some.domain>
|
|||
|
Subject: test mail
|
|||
|
Date: Sat, 23 Jun 2001 16:26:43 +0900
|
|||
|
Message-Id: <unique.message.id.string@some.domain>
|
|||
|
|
|||
|
This is test mail.
|
|||
|
EndOfMail
|
|||
|
}
|
|||
|
|
|||
|
=== <20><><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ä<EFBFBD><EFBFBD><EFBFBD> SMTP#finish <20><><EFBFBD>Ƥ<EFBFBD><C6A4>ǥ<EFBFBD><C7A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD>Ф<EFBFBD><D0A4><EFBFBD>
|
|||
|
<EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>File <20>Τ褦<CEA4><E8A4A6> GC <20><><EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD> close <20><><EFBFBD><EFBFBD><EFBFBD>뤳<EFBFBD>Ȥ⤢<C8A4><E2A4A2><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤȤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> finish <20><><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD>ݤ<F2B8ABB3><DDA4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>٤Ƹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD>finish <20><>ɬ<EFBFBD><C9AC><EFBFBD>Ƥ<EFBFBD><C6A4>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
<EFBFBD>ޤ<EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD>å<EFBFBD><EFBFBD>դ<EFBFBD><EFBFBD><EFBFBD> SMTP.start/SMTP#start <20><><EFBFBD>Ȥ<EFBFBD><C8A4>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD> finish <20><>
|
|||
|
<EFBFBD>Ƥ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>ʸ¤<EFBFBD><EFBFBD>֥<EFBFBD><EFBFBD>å<EFBFBD><EFBFBD>դ<EFBFBD><EFBFBD><EFBFBD> start <20><><EFBFBD>Ȥ<EFBFBD><C8A4>Τ<EFBFBD>
|
|||
|
<EFBFBD>褤<EFBFBD>Ǥ<EFBFBD><EFBFBD>礦<EFBFBD><EFBFBD>
|
|||
|
|
|||
|
# using SMTP#finish
|
|||
|
smtp = Net::SMTP.start( 'your.smtp.server', 25 )
|
|||
|
smtp.send_mail mail_string, 'from@address', 'to@address'
|
|||
|
smtp.finish
|
|||
|
|
|||
|
# using block form of SMTP.start
|
|||
|
Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp|
|
|||
|
smtp.send_mail mail_string, 'from@address', 'to@address'
|
|||
|
}
|
|||
|
|
|||
|
=== ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
<EFBFBD>ҤȤľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD>ʸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD>(<28>ҥ<EFBFBD><D2A5>ɥ<EFBFBD><C9A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><><EFBFBD>Ȥä<C8A4><C3A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
each <20><EFBFBD>åɤ<C3A5><C9A4><EFBFBD><EFBFBD>ä<EFBFBD><C3A4><EFBFBD><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4>ʤ<EFBFBD><CAA4>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD>뤳<EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>
|
|||
|
<EFBFBD>ʲ<EFBFBD><EFBFBD><EFBFBD> File <20><><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>
|
|||
|
|
|||
|
require 'net/smtp'
|
|||
|
Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp|
|
|||
|
File.open( 'Mail/draft/1' ) {|f|
|
|||
|
smtp.send_mail f, 'your@mail.address', 'to@some.domain'
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
=== HELO <20>ɥᥤ<C9A5><E1A5A4>
|
|||
|
|
|||
|
SMTP <20>Ǥϥ<CFA5><E1A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¦<EFBFBD>Υۥ<CEA5><DBA5>Ȥ<EFBFBD>̾<EFBFBD><CCBE> (HELO <20>ɥᥤ<C9A5><E1A5A4><EFBFBD>ȸƤ<C8B8>) <20><><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΤǤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Net::SMTP <20>ǤϤȤꤢ<C8A4><EAA4A2><EFBFBD><EFBFBD> localhost.localdomain <20><>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD> SMTP <20><><EFBFBD><EFBFBD><EFBFBD>ФϤ<D0A4><CFA4><EFBFBD> HELO <20>ɥᥤ<C9A5><E1A5A4>
|
|||
|
<EFBFBD>ˤ<EF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<20>ɥᥤ<C9A5><E1A5A4><EFBFBD>Ϥ<EFBFBD><CFA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD><CFA4>Τ<EFBFBD>
|
|||
|
<EFBFBD>٥<EFBFBD><EFBFBD>ȤǤ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
HELO <20>ɥᥤ<C9A5><E1A5A4><EFBFBD><EFBFBD> SMTP.start/SMTP#start <20><><EFBFBD>軰<EFBFBD><E8BBB0><EFBFBD><EFBFBD> helo_domain <20>˻<EFBFBD><CBBB><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
Net::SMTP.start( 'your.smtp.server', 25,
|
|||
|
'mail.from.domain' ) {|smtp|
|
|||
|
|
|||
|
<EFBFBD>褯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>륢<EFBFBD>åץۥ<EFBFBD><EFBFBD>Ȥξ<EFBFBD><EFBFBD>硢HELO <20>ɥᥤ<C9A5><E1A5A4><EFBFBD>ˤ<EFBFBD> ISP <20>Υ<CEA5><E1A1BC>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ФΥɥᥤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȤäƤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ф<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>̤<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
== class Net::SMTP
|
|||
|
|
|||
|
=== <20><><EFBFBD>饹<EFBFBD><EFBFBD>å<EFBFBD>
|
|||
|
|
|||
|
: new( address, port = 25 )
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SMTP <20><><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>address <20><>SMTP<54><50><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>FQDN<44>ǡ<EFBFBD>
|
|||
|
port <20><><EFBFBD><EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><DDA1><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<CEA5>åɤǤϤޤ<CFA4><DEA4><EFBFBD>³<EFBFBD>Ϥ<EFBFBD><CFA4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
: start( address, port = 25, helo_domain = 'localhost.localdomain', account = nil, password = nil, authtype = nil )
|
|||
|
: start( address, port = 25, helo_domain = 'localhost.localdomain', account = nil, password = nil, authtype = nil ) {|smtp| .... }
|
|||
|
<20>ʲ<EFBFBD><CAB2><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>
|
|||
|
Net::SMTP.new(address,port).start(helo_domain,account,password,authtype)
|
|||
|
|
|||
|
# example
|
|||
|
Net::SMTP.start( 'your.smtp.server' ) {
|
|||
|
smtp.send_mail mail_string, 'from@mail.address', 'dest@mail.address'
|
|||
|
}
|
|||
|
|
|||
|
=== <20><EFBFBD>å<EFBFBD>
|
|||
|
|
|||
|
: start( helo_domain = <local host name>, account = nil, password = nil, authtype = nil )
|
|||
|
: start( helo_domain = <local host name>, account = nil, password = nil, authtype = nil ) {|smtp| .... }
|
|||
|
TCP <20><><E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FBFBD>
|
|||
|
<20><> :plain <20><> :cram_md5 <20><><EFBFBD><EFBFBD><EFBFBD>ꤷ<EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>
|
|||
|
|
|||
|
: active?
|
|||
|
SMTP <20><><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><F3A4ACB3>Ϥ<EFBFBD><CFA4><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>鿿<EFBFBD><E9BFBF>
|
|||
|
|
|||
|
: address
|
|||
|
<20><>³<EFBFBD><C2B3><EFBFBD>륢<EFBFBD>ɥ쥹
|
|||
|
|
|||
|
: port
|
|||
|
<20><>³<EFBFBD><C2B3><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><DDA1><EFBFBD><EFBFBD>ֹ<EFBFBD>
|
|||
|
|
|||
|
: open_timeout
|
|||
|
: open_timeout=(n)
|
|||
|
<20><>³<EFBFBD><C2B3><EFBFBD><EFBFBD><EFBFBD>Ԥĺ<D4A4><C4BA><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>äƤ⥳<C6A4>ͥ<EFBFBD><CDA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㳰 TimeoutError <20><>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>
|
|||
|
|
|||
|
: read_timeout
|
|||
|
: read_timeout=(n)
|
|||
|
<20>ɤߤ<C9A4><DFA4><EFBFBD> (read(1) <20><><EFBFBD><EFBFBD>) <20>ǥ֥<C7A5><D6A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD>Ƥ褤<C6A4><E8A4A4><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>äƤ<C3A4><C6A4>ɤߤ<C9A4><DFA4><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㳰 TimeoutError <20><>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>
|
|||
|
|
|||
|
: finish
|
|||
|
SMTP <20><><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><F3B3ABBB><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4>Υ<CEA5>åɤ<C3A5>
|
|||
|
<20>ƤФ줿<D0A4><ECA4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㳰 IOError <20><>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>
|
|||
|
|
|||
|
: send_mail( mailsrc, from_addr, *to_addrs )
|
|||
|
mailsrc <20><><EFBFBD><EFBFBD><E1A1BC><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>mailsrc <20><> each <20><><EFBFBD>ƥ졼<C6A5><ECA1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<20><><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥʤ<C8A4><CAA4>ʤ<EFBFBD><CAA4>Ǥ<C7A4><E2B9BD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD> (<28><><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD> String <20><> File)<29><>
|
|||
|
from_domain <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<CEA5>륢<EFBFBD>ɥ쥹 ('...@...'<27>Τ<EFBFBD><CEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τ<EFBFBD><CEA4><EFBFBD>) <20>ǡ<EFBFBD>
|
|||
|
to_addrs <20>ˤ<EFBFBD><CBA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>륢<EFBFBD>ɥ쥹<C9A5><ECA5B9><EFBFBD>¤٤ޤ<D9A4><DEA4><EFBFBD>
|
|||
|
|
|||
|
# example
|
|||
|
Net::SMTP.start( 'your.smtp.server' ) {|smtp|
|
|||
|
smtp.send_mail mail_string,
|
|||
|
'from@mail.address',
|
|||
|
'dest@mail.address' 'dest2@mail.address'
|
|||
|
}
|
|||
|
|
|||
|
: ready( from_addr, *to_addrs ) {|adapter| .... }
|
|||
|
<20><EFBFBD><E1A1BC><EFBFBD><EFBFBD><F1A4ADA4>ߤν<DFA4><CEBD><EFBFBD><EFBFBD><EFBFBD><F2A4B7A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǡ<EFBFBD>write <20><EFBFBD>åɤ<C3A5><C9A4><EFBFBD><EFBFBD>ĥ<EFBFBD><C4A5>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD>
|
|||
|
<20>֥<EFBFBD><D6A5>å<EFBFBD><C3A5>ˤ<EFBFBD><CBA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>from_addr <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>륢<EFBFBD>ɥ쥹<C9A5><ECA5B9> to_addrs <20><>
|
|||
|
<20><><EFBFBD><EFBFBD><EFBFBD>Υ<CEA5><E1A1BC><EFBFBD>ܥå<DCA5><C3A5><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>
|
|||
|
|
|||
|
# example
|
|||
|
Net::SMTP.start( 'your.smtp.server', 25 ) {|smtp|
|
|||
|
smtp.ready( 'from@mail.addr', 'dest@mail.addr' ) {|f|
|
|||
|
f.puts 'From: aamine@loveruby.net'
|
|||
|
f.puts 'To: someone@somedomain.org'
|
|||
|
f.puts 'Subject: test mail'
|
|||
|
f.puts
|
|||
|
f.puts 'This is test mail.'
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
== ȯ<><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㳰
|
|||
|
|
|||
|
<EFBFBD><EFBFBD><EFBFBD>å<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (SMTP <20><><EFBFBD>٥<EFBFBD><D9A5><EFBFBD>) <20><><EFBFBD>顼<EFBFBD><E9A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ä<EFBFBD><C3A4><EFBFBD><EFBFBD>硢
|
|||
|
<EFBFBD>ʲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㳰<EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
: Net::ProtoSyntaxError
|
|||
|
SMTP <20><><EFBFBD>ޥ<EFBFBD><DEA5>ɤι<C9A4>ʸ<EFBFBD>ߥ<EFBFBD>(500<30><30><EFBFBD><EFBFBD>)
|
|||
|
: Net::ProtoFatalError
|
|||
|
<20><><EFBFBD><EFBFBD>Ū<EFBFBD>ʥ<EFBFBD><CAA5>顼(550<35><30><EFBFBD><EFBFBD>)
|
|||
|
: Net::ProtoUnknownError
|
|||
|
ͽ<><CDBD><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD>顼<EFBFBD><E9A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>餯<EFBFBD>Х<EFBFBD>
|
|||
|
: Net::ProtoServerBusy
|
|||
|
<20><><EFBFBD><EFBFBD>Ū<EFBFBD>ʥ<EFBFBD><CAA5>顼(420/450<35><30><EFBFBD><EFBFBD>)
|
|||
|
|
|||
|
=end
|