summaryrefslogtreecommitdiff
path: root/lib/net/smtp.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-17 15:00:13 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-17 15:00:13 +0000
commit6f4751f5f63d177534f34e0c278967883e11c035 (patch)
tree8de6c51c87b0c3be10506c43eb83291d58f43790 /lib/net/smtp.rb
parent9d228b13deccfdf23f44e2c465f723a2a7b3bcbd (diff)
Version 1.1.0
o http.rb o support class swap o Net.quote git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/smtp.rb')
-rw-r--r--lib/net/smtp.rb67
1 files changed, 32 insertions, 35 deletions
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 6294512..dd74cdc 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -1,11 +1,11 @@
=begin
-= Net module version 1.0.3 reference manual
+= net/smtp.rb
-smtp.rb written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-This library is distributed under the terms of Ruby style license.
-You can freely redistribute/modify/copy this file.
+This library is distributed under the terms of Ruby license.
+You can freely distribute/modify this file.
=end
@@ -13,6 +13,9 @@ You can freely redistribute/modify/copy this file.
require 'net/session'
+module Net
+
+
=begin
== Net::SMTPSession
@@ -27,18 +30,6 @@ Net::Session
This method create new SMTPSession object.
-=end
-
-module Net
-
- class SMTPSession < Session
-
- def proto_initialize
- @proto_type = SMTPCommand
- @port = 25
- end
-
-=begin
=== Methods
@@ -65,26 +56,30 @@ module Net
=end
+ class SMTPSession < Session
+
+ Version = '1.1.0'
+
+ session_setvar :port, '25'
+ session_setvar :command_type, 'SMTPCommand'
+
+
def sendmail( mailsrc, fromaddr, toaddrs )
- @proto.mailfrom( fromaddr )
- @proto.rcpt( toaddrs )
+ @proto.mailfrom fromaddr
+ @proto.rcpt toaddrs
@proto.data
- @proto.sendmail( mailsrc )
+ @proto.sendmail mailsrc
end
private
- def do_start( helodom = nil )
+ def do_start( helodom = ENV['HOSTNAME'] )
unless helodom then
- helodom = ENV[ 'HOSTNAME' ]
+ raise ArgumentError, "cannot get hostname"
end
- @proto.helo( helodom )
- end
-
- def do_finish
- @proto.quit
+ @proto.helo helodom
end
end
@@ -111,17 +106,17 @@ Net::Command
: helo( helo_domain )
- This method send "HELO" command and start SMTP session.<br>
+ This method send "HELO" command and start SMTP session.
helo_domain is localhost's FQDN.
: mailfrom( from_addr )
- This method sends "MAIL FROM" command.<br>
+ This method sends "MAIL FROM" command.
from_addr is your mail address(????@????).
: rcpt( to_addrs )
- This method sends "RCPT TO" command.<br>
+ This method sends "RCPT TO" command.
to_addrs is array of mail address(???@???) of destination.
: data( mailsrc )
@@ -137,6 +132,12 @@ Net::Command
class SMTPCommand < Command
+ def initialize( sock )
+ super
+ check_reply SuccessCode
+ end
+
+
def helo( fromdom )
@socket.writeline( 'HELO ' << fromdom )
check_reply( SuccessCode )
@@ -163,10 +164,11 @@ Net::Command
end
- def sendmail( mailsrc )
+ def writemail( mailsrc )
@socket.write_pendstr( mailsrc )
check_reply( SuccessCode )
end
+ alias sendmail writemail
private
@@ -211,9 +213,4 @@ Net::Command
end
-
- unless Session::Version == '1.0.3' then
- $stderr.puts "WARNING: wrong version of session.rb & smtp.rb"
- end
-
end