From 6f4751f5f63d177534f34e0c278967883e11c035 Mon Sep 17 00:00:00 2001 From: aamine Date: Fri, 17 Dec 1999 15:00:13 +0000 Subject: 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 --- lib/net/smtp.rb | 67 +++++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'lib/net/smtp.rb') diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 6294512ffc..dd74cdcdb4 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 +written by Minero Aoki -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.
+ This method send "HELO" command and start SMTP session. helo_domain is localhost's FQDN. : mailfrom( from_addr ) - This method sends "MAIL FROM" command.
+ This method sends "MAIL FROM" command. from_addr is your mail address(????@????). : rcpt( to_addrs ) - This method sends "RCPT TO" command.
+ 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 -- cgit v1.2.3