1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

How to Send Email with Ruby


A "heredoc" is a way of making multi-line strings easy to type. It's possible to form multi-line strings with the string concatenation operator (such as "string1" + "string2"), but this operation is slow and inefficient and it adds extra syntax to every line as well. The heredoc syntax starts with something that looks like this: <<END. This means every line after this one will be part of a string, not a Ruby program. END on a line by itself will end the multi-line string. You can use any other identifier instead of END if you want, but END is the common convention.

 #!/usr/bin/env ruby
 require 'net/smtp'
 ) do|smtp|
   message = <
  1. About.com
  2. Technology
  3. Ruby
  4. Tutorials
  5. Using Heredocs

©2014 About.com. All rights reserved.