summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/net/protocol.rb6
-rw-r--r--lib/net/smtp.rb20
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index f234371a69..f438a86c77 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -64,7 +64,7 @@ module Net
class Protocol
- Version = '1.1.24'
+ Version = '1.1.25'
class << self
@@ -664,10 +664,10 @@ module Net
end
def each_crlf_line( src )
- str = m = nil
- beg = 0
+ str = m = beg = nil
adding( src ) do
+ beg = 0
buf = @wbuf
while buf.index( /\n|\r\n|\r/, beg ) do
m = $~
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index bc346d3138..57e4116f2e 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -38,11 +38,15 @@ Net::Protocol
If account and password are given, is trying to get authentication
by using AUTH command. "authtype" is :plain (symbol) or :cram_md5.
+: send_mail( mailsrc, from_addr, to_addrs )
: sendmail( mailsrc, from_addr, 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.
+ from_addr must be String.
+ to_addrs must be Array of String, or String.
+
Exceptions which SMTP raises are:
* Net::ProtoSyntaxError: syntax error (errno.500)
* Net::ProtoFatalError: fatal error (errno.550)
@@ -91,13 +95,14 @@ module Net
attr :esmtp
- def sendmail( mailsrc, fromaddr, toaddrs )
- do_ready fromaddr, toaddrs
+ def send_mail( mailsrc, from_addr, to_addrs )
+ do_ready from_addr, to_addrs
@command.write_mail mailsrc, nil
end
+ alias sendmail send_mail
- def ready( fromaddr, toaddrs, &block )
- do_ready fromaddr, toaddrs
+ def ready( from_addr, to_addrs, &block )
+ do_ready from_addr, to_addrs
@command.write_mail nil, block
end
@@ -105,9 +110,10 @@ module Net
private
- def do_ready( fromaddr, toaddrs )
- @command.mailfrom fromaddr
- @command.rcpt toaddrs
+ def do_ready( from_addr, to_addrs )
+ to_addrs = [to_addrs] if String === to_addrs
+ @command.mailfrom from_addr
+ @command.rcpt to_addrs
@command.data
end