Created
October 21, 2013 19:28
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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