1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.27.
* lib/net/protocol.rb: writing methods returns written byte size.
* lib/net/smtp.rb: send_mail accepts many destinations.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aamine 2000-08-16 19:26:07 +00:00
parent 82178a5529
commit 79c2d60971
5 changed files with 56 additions and 38 deletions

View file

@ -1,3 +1,11 @@
Thu Aug 17 04:26:31 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.27.
* lib/net/protocol.rb: writing methods returns written byte size.
* lib/net/smtp.rb: send_mail accepts many destinations.
Tue Aug 15 17:30:59 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (frame_dup): should set flag FRAME_MALLOC after

View file

@ -1,12 +1,13 @@
=begin
= net/http.rb version 1.1.27
= net/http.rb version 1.1.28
maintained by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
This file is derived from "http-access.rb".
This library is distributed under the terms of the Ruby license.
You can freely distribute/modify this library.
This program is free software.
You can distribute/modify this program under
the terms of the Ruby Distribute License.
= class HTTP

View file

@ -1,11 +1,12 @@
=begin
= net/pop.rb version 1.1.27
= net/pop.rb version 1.1.28
written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
This library is distributed under the terms of the Ruby license.
You can freely distribute/modify this library.
This program is free software.
You can distribute/modify this program under
the terms of the Ruby Distribute License.
== Net::POP3

View file

@ -1,11 +1,12 @@
=begin
= net/protocol.rb version 1.1.27
= net/protocol.rb version 1.1.28
written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
This library is distributed under the terms of the Ruby license.
You can freely distribute/modify this library.
This program is free software.
You can distribute/modify this program under
the terms of the Ruby Distribute License.
== Net::Protocol
@ -64,7 +65,7 @@ module Net
class Protocol
Version = '1.1.27'
Version = '1.1.28'
class << self
@ -75,7 +76,7 @@ module Net
if iterator? then
instance.start( *args ) { yield instance }
else
instance.start *args
instance.start( *args )
instance
end
end
@ -164,7 +165,7 @@ module Net
begin
connect
do_start *args
do_start( *args )
@active = true
yield self if iterator?
ensure
@ -639,10 +640,13 @@ module Net
def wpend_in( src )
line = nil
pre = @writtensize
each_crlf_line( src ) do |line|
do_write '.' if line[0] == ?.
do_write line
end
@writtensize - pre
end
def use_each_crlf_line

View file

@ -1,11 +1,12 @@
=begin
= net/smtp.rb version 1.1.27
= net/smtp.rb version 1.1.28
written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
This library is distributed under the terms of the Ruby license.
You can freely distribute/modify this library.
This program is free software.
You can distribute/modify this program under
the terms of the Ruby Distribute License.
== Net::SMTP
@ -21,7 +22,7 @@ Net::Protocol
: start( address = 'localhost', port = 25, *protoargs )
: start( address = 'localhost', port = 25, *protoargs ) {|smtp| .... }
same to Net::SMTP.new( address, port ).start( *protoargs )
is equal to Net::SMTP.new( address, port ).start( *protoargs )
=== Methods
@ -38,14 +39,14 @@ Net::Protocol
If account and password are given, is trying to get authentication
by using AUTH command. "authtype" is :plain (symbol) or :cram_md5.
: send_mail( mailsrc, from_addr, to_addrs )
: sendmail( mailsrc, from_addr, to_addrs )
This method sends 'mailsrc' as mail. SMTPSession read strings
: send_mail( mailsrc, from_addr, *to_addrs )
: sendmail( mailsrc, from_addr, *to_addrs )
This method sends 'mailsrc' as mail. SMTP read strings
from 'mailsrc' by calling 'each' iterator, and convert them
into "\r\n" terminated string when write.
from_addr must be String.
to_addrs must be Array of String, or String.
to_addrs must be a String(s) or an Array of String.
Exceptions which SMTP raises are:
* Net::ProtoSyntaxError: syntax error (errno.500)
@ -53,6 +54,12 @@ Net::Protocol
* Net::ProtoUnknownError: unknown error
* Net::ProtoServerBusy: temporary error (errno.420/450)
# usage example
Net::SMTP.start( 'localhost', 25 ) do |smtp|
smtp.send_mail mail_string, 'from-addr@foo.or.jp', 'to-addr@bar.or.jp'
end
: ready( from_addr, to_addrs ) {|adapter| .... }
This method stands by the SMTP object for sending mail.
In the block of this iterator, you can call ONLY 'write' method
@ -60,7 +67,7 @@ Net::Protocol
# usage example
SMTP.start( 'localhost', 25 ) do |smtp|
Net::SMTP.start( 'localhost', 25 ) do |smtp|
smtp.ready( from, to ) do |adapter|
adapter.write str1
adapter.write str2
@ -69,8 +76,8 @@ Net::Protocol
end
: finish
This method ends SMTP.
If protocol had not started, do nothind and return false.
finishes SMTP session.
If SMTP session had not started, do nothing and return false.
=end
@ -92,17 +99,17 @@ module Net
@esmtp = true
end
attr :esmtp
def send_mail( mailsrc, from_addr, to_addrs )
do_ready from_addr, to_addrs
def send_mail( mailsrc, from_addr, *to_addrs )
do_ready from_addr, to_addrs.flatten
@command.write_mail mailsrc, nil
end
alias sendmail send_mail
def ready( from_addr, to_addrs, &block )
do_ready from_addr, to_addrs
def ready( from_addr, *to_addrs, &block )
do_ready from_addr, to_addrs.flatten
@command.write_mail nil, block
end
@ -111,7 +118,9 @@ module Net
def do_ready( from_addr, to_addrs )
to_addrs = [to_addrs] if String === to_addrs
if to_addrs.empty? then
raise ArgumentError, 'mail destination does not given'
end
@command.mailfrom from_addr
@command.rcpt to_addrs
@command.data
@ -119,12 +128,10 @@ module Net
def do_start( helodom = nil,
user = nil, secret = nil, authtype = nil )
helodom ||= ::Socket.gethostname
unless helodom then
helodom = ::Socket.gethostname
unless helodom then
raise ArgumentError,
"cannot get localhost name; try 'smtp.start(local_host_name)'"
end
raise ArgumentError,
"cannot get localhost name; try 'smtp.start(local_host_name)'"
end
begin
@ -234,13 +241,11 @@ module Net
getok 'DATA', ContinueCode
end
def write_mail( mailsrc, block )
@socket.write_pendstr mailsrc, block
check_reply SuccessCode
end_critical
end
alias sendmail write_mail
def quit
@ -276,7 +281,6 @@ module Net
def read_reply
arr = []
while true do
str = @socket.readline
break unless str[3] == ?- # ex: "210-..."
@ -284,7 +288,7 @@ module Net
end
arr.push str
return arr
arr
end
end