Skip to content

Instantly share code, notes, and snippets.

@caseywatts
Last active August 29, 2015 14:15
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 caseywatts/cb0ca98e1b27342a6720 to your computer and use it in GitHub Desktop.
Save caseywatts/cb0ca98e1b27342a6720 to your computer and use it in GitHub Desktop.
MailMe
#!/usr/bin/env ruby
#
# gem install pony
require 'pony'
if ARGV[0]
my_filename = ARGV[0]
my_email = `git config --global user.email`
Pony.mail(to: my_email, from:my_email, subject: "Mailing Myself a File", body: "ohai, yes this is a file you sent yourself just now.", attachments: {my_filename => File.read(my_filename)})
else
puts "please provide as a single argument the name of the file to send to yourself"
end

MailMe is a super short ruby script that uses pony to send yourself a file from the computer you're on.

Installation

git clone https://gist.github.com/cb0ca98e1b27342a6720.git ~/mailme
gem install pony
cd ~/mailme
ln -s $PWD/mailme /usr/local/bin/

The mailme script is stored in the file ~/mailme/mailme, and symlinked to your /usr/local/bin/. After restarting your terminal, the command mailme will be available.

Usage

mailme FILENAME.TXT

  • The "me" is gleaned from your git config --global user.email
  • The file that is sent is provided as the first argument to the command.
  • Warning: mail sent from the local computer via pony is often caught in a spam filter, make sure the message actually arrives in your inbox.
@jhirbour
Copy link

jhirbour commented Feb 9, 2015

@caseywatts
Copy link
Author

The user interface I really want is mailme FILENAME.

I can imagine rewriting this to use mail and remove the ruby dependency and that'd be great! But I've got a stumbling point.

OS X doesn't come with the command line utility mutt (a MIME utility needed to do attachments with mail). pony brings in a ruby MIME package and uses it in conjunction with mail. Right now I suspect the ruby dependency is more lightweight than one would be on mutt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment