class Net::SMTP

def data(msgstr = nil, &block) #:yield: stream

:yield: stream

}
f.puts "Check vm.c:58879."
f.puts ""
f.puts "Subject: I found a bug"
f.puts "To: betty@example.com"
f.puts "From: john@example.com"
smtp.data {|f|
# Example 2 (by block)

EndMessage
Check vm.c:58879.

Subject: I found a bug
To: betty@example.com
From: john@example.com
smtp.data(<# Example 1 (by string)

You must write message before the block is closed.
If block is given, yield a message writer stream.
If +msgstr+ is given, sends it as a message.
This method sends a message.
def data(msgstr = nil, &block)   #:yield: stream
  if msgstr and block
    raise ArgumentError, "message and block are exclusive"
  end
  unless msgstr or block
    raise ArgumentError, "message or block is required"
  end
  res = critical {
    check_continue get_response('DATA')
    socket_sync_bak = @socket.io.sync
    begin
      @socket.io.sync = false
      if msgstr
        @socket.write_message msgstr
      else
        @socket.write_message_by_block(&block)
      end
    ensure
      @socket.io.flush
      @socket.io.sync = socket_sync_bak
    end
    recv_response()
  }
  check_response res
  res
end