From ec8a9bba354e3bcdb7b7b004d3ce3d148bd9fc7f Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 13 Oct 1999 07:29:15 +0000 Subject: maillib-1.0.2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/smtp.rb | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 97 insertions(+), 6 deletions(-) (limited to 'lib/net/smtp.rb') diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 9f534c20c0..de97feaa23 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -1,12 +1,34 @@ -# -# smtp.rb version 1.0.1 -# -# author Minero Aoki -# +=begin + += Net module version 1.0.2 reference manual + +smtp.rb written by Minero Aoki + +This library is distributed under the terms of Ruby style license. +You can freely redistribute/modify/copy this file. + +=end + require 'net/session' +=begin + +== Net::SMTPSession + +=== Super Class + +Net::Session + +=== Class Methods + +: new( address = 'localhost', port = 25 ) + + This method create new SMTPSession object. + +=end + module Net class SMTPSession < Session @@ -16,6 +38,33 @@ module Net @port = 25 end +=begin + +=== Methods + +: start( helo_domain = ENV['HOSTNAME'] ) + + This method opens TCP connection and start SMTP session. + If session had been started, do nothing and return false. + +: sendmail( mailsrc, from_domain, to_addrs ) + + This method sends 'mailsrc' as mail. SMTPSession read strings from 'mailsrc' + by calling 'each' iterator, and convert them into "\r\n" terminated string when write. + + SMTPSession's Exceptions are: + * Protocol::ProtoSyntaxError: syntax error (errno.500) + * Protocol::ProtoFatalError: fatal error (errno.550) + * Protocol::ProtoUnknownError: unknown error + * Protocol::ProtoServerBusy: temporary error (errno.420/450) + +: finish + + This method closes SMTP session. + If session had not started, do nothind and return false. + +=end + def sendmail( mailsrc, fromaddr, toaddrs ) @proto.mailfrom( fromaddr ) @proto.rcpt( toaddrs ) @@ -43,6 +92,48 @@ module Net SMTP = SMTPSession +=begin + +== Net::SMTPCommand + +=== Super Class + +Net::Command + +=== Class Methods + +: new( socket ) + + This method creates new SMTPCommand object, and open SMTP session. + + +=== Methods + +: helo( helo_domain ) + + This method send "HELO" command and start SMTP session.
+ helo_domain is localhost's FQDN. + +: mailfrom( from_addr ) + + This method sends "MAIL FROM" command.
+ from_addr is your mail address(????@????). + +: rcpt( to_addrs ) + + This method sends "RCPT TO" command.
+ to_addrs is array of mail address(???@???) of destination. + +: data( mailsrc ) + + This method send 'mailsrc' as mail. SMTP reads strings from 'mailsrc' + by calling 'each' iterator. + +: quit + + This method sends "QUIT" command and ends SMTP session. + +=end class SMTPCommand < Command @@ -121,7 +212,7 @@ module Net end - unless Session::Version == '1.0.1' then + unless Session::Version == '1.0.2' then $stderr.puts "WARNING: wrong version of session.rb & smtp.rb" end -- cgit v1.2.3