Skip to content

Instantly share code, notes, and snippets.

@aliou
Created April 12, 2012 05:49
Show Gist options
  • Save aliou/2364807 to your computer and use it in GitHub Desktop.
Save aliou/2364807 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'gmail'
config_file = "#{ENV['HOME']}/.gmail"
unless File.exist?(config_file)
puts "You need to type your email and password (one per line) into `~/.gmail`."
exit!(1)
end
# if ARGV[0].nil?
# puts "You need to specify a file to send."
# exit!(1)
# end
username,password = File.read(config_file).split("\n")
gmail = Gmail.connect!(username, password)
gmail.deliver do
to "<email_adress>"
subject "<Subject>"
text_part do
body "<message>"
end
# ARGV.each do |fic|
# add_file fic
# end
end
gmail.logout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment