Sending a file attachment using the gmail gem

require 'gmail'


gmail = Gmail.new('some_user@gmail.com', 'password')

gmail.deliver do

  to "jr001@jamesrobertson.eu"
  subject "Having fun in Puerto Rico!"

  text_part do
    body "Text of plaintext message."
  end
  html_part do
    content_type 'text/html; charset=UTF-8'
    body "<p>Text of <em>html</em> message.</p>"
  end

  add_file '/tmp/fun.txt'
end

The above code demonstrates sending an email message with a file attachment.

See also