Skip to content

Instantly share code, notes, and snippets.

@nerab
Created November 30, 2011 21:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerab/1410840 to your computer and use it in GitHub Desktop.
Save nerab/1410840 to your computer and use it in GitHub Desktop.
Send eBooks to a Kindle from the MacOS command line
  1. Install msmtp, a simple sendmail stand-in that sends mail via a relay host (which is what you want, in almost all cases):

     brew install msmtp --with-macosx-keyring
    

    The flag with-macosx-keyring will make msmtp use the MacOS keychain, which is a pretty secure way to keep your mail account password secure.

  2. Configure it as described in this article. Don't use the manual installation method described there, Homebrew (which we used in step 1) is way more convenient.

  3. Have mail use msmtp instead of sendmail by creating .mailrc with the following content (or adding it, it the file already exists):

     set sendmail=/usr/local/bin/msmtp
    
  4. As we are going to use mutt to send mail with attachments, we just symlink the .mailrc created above:

     ln -s .mailrc .muttrc
    

    If you already have a .muttrc, just add the following line to it:

     set sendmail=/usr/local/bin/msmtp
    
  5. Add this function to ~/.bash_profile:

     mail2kindle () 
     { 
       echo ebook | mutt -s ebook -a "$1" -- example@free.kindle.com
     }
    

    When adding this, you obviously need to replace example@free.kindle.com with the email address of your kindle.

  6. At Amazon's My Kindle page, add the sender address to the list of eMail addresses that are authorized to send books to your Kindle.

  7. You can now send eBooks to your kindle with the following command:

     mail2kindle book.mobi
    
@NightMachinery
Copy link

Using mutt with no config but the environment variable EMAIL works just fine. It also doesn’t have gmail’s 25mb attachment limit.

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