The following example uses the data stream to compose a message. The data stream is a way of appending data to the end of a Ruby file and reading it using the DATA IO object. The DATA IO object is just like any of the other IO objects such as STDIN, STDOUT or an object returned by File.open. Calling DATA.read will read everything after the __END__ keyword into a string.
#!/usr/bin/env ruby require 'net/smtp' Net::SMTP.start( 'mail.isp.com', 25, 'isp.com' ) do|smtp| message = DATA.read smtp.send_message( message, 'firstname.lastname@example.org', 'email@example.com' ) smtp.finish end __END__ From: firstname.lastname@example.org To: email@example.com Subject: This is a message sent by Ruby! This is the body of the message. It can be as long as you like.