Skip to content

Instantly share code, notes, and snippets.

@caseywatts
Last active Aug 29, 2015
Embed
What would you like to do?
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

This comment has been minimized.

@caseywatts

This comment has been minimized.

Copy link
Owner Author

@caseywatts caseywatts commented Feb 9, 2015

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