Skip to content

Instantly share code, notes, and snippets.

@mdunsmuir
Created October 21, 2013 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdunsmuir/7089484 to your computer and use it in GitHub Desktop.
Save mdunsmuir/7089484 to your computer and use it in GitHub Desktop.
handy script for emailing files to yourself from places where other means of transfer are unavailable.
require 'mail'
require 'iconv'
file, subj, email = *ARGV
raise "usage: #{File.basename(__FILE__)} <file> <subject> <email>" unless email
file_content = IO.read(file)
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
file_content = ic.iconv(file_content << ' ')[0..-2]
Mail.new{
from "helpfulguy@fakeemails.com"
subject subj
to email
body "attached..."
add_file :filename => File.basename(file), :content => file_content
}.deliver!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment