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.25.

* lib/net/protocol.rb (each_crlf_line): beg = 0 is needed in adding{}
* lib/net/smtp.rb: allow String for to_addr of SMTP#sendmail


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aamine 2000-07-01 18:28:24 +00:00
parent 951d81cab8
commit 5eccd28bb3
2 changed files with 16 additions and 10 deletions

View file

@ -64,7 +64,7 @@ module Net
class Protocol class Protocol
Version = '1.1.24' Version = '1.1.25'
class << self class << self
@ -664,10 +664,10 @@ module Net
end end
def each_crlf_line( src ) def each_crlf_line( src )
str = m = nil str = m = beg = nil
beg = 0
adding( src ) do adding( src ) do
beg = 0
buf = @wbuf buf = @wbuf
while buf.index( /\n|\r\n|\r/, beg ) do while buf.index( /\n|\r\n|\r/, beg ) do
m = $~ m = $~

View file

@ -38,11 +38,15 @@ Net::Protocol
If account and password are given, is trying to get authentication If account and password are given, is trying to get authentication
by using AUTH command. "authtype" is :plain (symbol) or :cram_md5. by using AUTH command. "authtype" is :plain (symbol) or :cram_md5.
: send_mail( mailsrc, from_addr, to_addrs )
: sendmail( mailsrc, from_addr, to_addrs ) : sendmail( mailsrc, from_addr, to_addrs )
This method sends 'mailsrc' as mail. SMTPSession read strings This method sends 'mailsrc' as mail. SMTPSession read strings
from 'mailsrc' by calling 'each' iterator, and convert them from 'mailsrc' by calling 'each' iterator, and convert them
into "\r\n" terminated string when write. into "\r\n" terminated string when write.
from_addr must be String.
to_addrs must be Array of String, or String.
Exceptions which SMTP raises are: Exceptions which SMTP raises are:
* Net::ProtoSyntaxError: syntax error (errno.500) * Net::ProtoSyntaxError: syntax error (errno.500)
* Net::ProtoFatalError: fatal error (errno.550) * Net::ProtoFatalError: fatal error (errno.550)
@ -91,13 +95,14 @@ module Net
attr :esmtp attr :esmtp
def sendmail( mailsrc, fromaddr, toaddrs ) def send_mail( mailsrc, from_addr, to_addrs )
do_ready fromaddr, toaddrs do_ready from_addr, to_addrs
@command.write_mail mailsrc, nil @command.write_mail mailsrc, nil
end end
alias sendmail send_mail
def ready( fromaddr, toaddrs, &block ) def ready( from_addr, to_addrs, &block )
do_ready fromaddr, toaddrs do_ready from_addr, to_addrs
@command.write_mail nil, block @command.write_mail nil, block
end end
@ -105,9 +110,10 @@ module Net
private private
def do_ready( fromaddr, toaddrs ) def do_ready( from_addr, to_addrs )
@command.mailfrom fromaddr to_addrs = [to_addrs] if String === to_addrs
@command.rcpt toaddrs @command.mailfrom from_addr
@command.rcpt to_addrs
@command.data @command.data
end end