summaryrefslogtreecommitdiff
path: root/lib/net/smtp.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-19 12:33:52 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-19 12:33:52 +0000
commit19f7f6ea122df49a54c0fe40791feab1a53f6cd9 (patch)
tree89d99ac69ec027324c5844faaed269f95b8a5753 /lib/net/smtp.rb
parentc1bfef949450c0ad55024670af2245a7833a59b4 (diff)
aamine
* lib/net/protocol.rb: rename Protocol.port to default_port. * lib/net/smtp.rb: ditto. * lib/net/pop.rb: ditto. * lib/net/http.rb: ditto. * lib/net/protocol.rb: rename BufferedSocket class to InternetMessageIO. * lib/net/smtp.rb: ditto. * lib/net/pop.rb: ditto. * lib/net/http.rb: ditto. * lib/net/protocol.rb: rename InternetMessageIO#write_pendstr to write_message. * lib/net/smtp.rb: ditto. * lib/net/protocol.rb: new method InternetMessageIO#through_message. * lib/net/smtp.rb: ditto. * lib/net/protocol.rb: rename InternetMessageIO#read_pendstr to read_message_to. * lib/net/pop.rb: ditto. * lib/net/protocol.rb: rename InternetMessageIO#read_pendlist to each_list_item * lib/net/pop.rb: ditto. * lib/net/protocol.rb: Now block size is 1024. * lib/net/smtp.rb: new methods SMTP#esmtp? and #esmtp=. * lib/net/http.rb: Using singleton method syntax instead of singleton class clause, to avoid behavior change of class variables in ruby 1.7. * lib/net/http.rb: HTTPResponse class does not inherit from Net::Response. * lib/net/http.rb: devide HTTP#connecting into {begin,end}_transport. * lib/net/http.rb: unused class Accumulator removed. * lib/net/http.rb: Net::HTTP reads response. not HTTPRequest. * lib/net/http.rb: proxy related class-instance-variables are not initialized correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/smtp.rb')
-rw-r--r--lib/net/smtp.rb49
1 files changed, 30 insertions, 19 deletions
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 363fc39088..8652f0f5d0 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -2,7 +2,7 @@
= net/smtp.rb
-Copyright (c) 1999-2001 Yukihiro Matsumoto
+Copyright (c) 1999-2002 Yukihiro Matsumoto
written & maintained by Minero Aoki <aamine@loveruby.net>
@@ -220,15 +220,25 @@ module Net
class SMTP < Protocol
- protocol_param :port, '25'
+ protocol_param :default_port, '25'
protocol_param :command_type, '::Net::SMTPCommand'
+ protocol_param :socket_type, '::Net::InternetMessageIO'
+
def initialize( addr, port = nil )
super
@esmtp = true
end
- attr :esmtp
+ def esmtp?
+ @esmtp
+ end
+
+ def esmtp=( bool )
+ @esmtp = bool
+ end
+
+ alias esmtp esmtp?
private
@@ -279,29 +289,28 @@ module Net
def send_mail( mailsrc, from_addr, *to_addrs )
do_ready from_addr, to_addrs.flatten
- command().write_mail mailsrc, nil
+ command().write_mail mailsrc
end
alias sendmail send_mail
def ready( from_addr, *to_addrs, &block )
do_ready from_addr, to_addrs.flatten
- command().write_mail nil, block
+ command().through_mail &block
end
private
def do_ready( from_addr, to_addrs )
- if to_addrs.empty? then
- raise ArgumentError, 'mail destination does not given'
- end
+ raise ArgumentError, 'mail destination does not given' if to_addrs.empty?
command().mailfrom from_addr
command().rcpt to_addrs
- command().data
end
end
+ SMTPSession = SMTP
+
class SMTPCommand < Command
@@ -366,15 +375,20 @@ module Net
end
end
- def data
- return unless begin_atomic
- getok 'DATA', ContinueCode
+ def write_mail( src )
+ atomic {
+ getok 'DATA', ContinueCode
+ @socket.write_message src
+ check_reply SuccessCode
+ }
end
- def write_mail( mailsrc, block )
- @socket.write_pendstr mailsrc, &block
- check_reply SuccessCode
- end_atomic
+ def through_mail( &block )
+ atomic {
+ getok 'DATA', ContinueCode
+ @socket.through_message(&block)
+ check_reply SuccessCode
+ }
end
def quit
@@ -421,9 +435,6 @@ module Net
# for backward compatibility
-
- SMTPSession = SMTP
-
module NetPrivate
SMTPCommand = ::Net::SMTPCommand
end