zlib / send to kindle

Send books to your Kindle from the terminal.

One command mails a file to your Kindle address through your own mail server. No browser, no upload page, nothing to drag anywhere.

zlib kindle send ./dune.epub
EPUB · PDF · DOCX · and more Any SMTP server Password never written to disk
$ zlib kindle

Setting it up once

Amazon lets you mail documents to a Kindle, and it accepts mail only from addresses you have approved. So the setup is two halves: tell zlib which mail server to send through, and tell Amazon that server's address is allowed to send to you.

  1. Install zlib

    Homebrew, winget, go install, or a prebuilt binary from the releases page.

    $ brew install heartleo/tap/zlib
  2. Point it at your mail server

    Running zlib kindle with no arguments opens a short form: your Kindle address, the address you are sending from, and the SMTP host and port. It defaults to smtp.gmail.com on port 587. The answers are saved to ~/.config/zlib/kindle.json.

    $ zlib kindle
    
      Kindle address   you@kindle.com
      From address     you@gmail.com
      SMTP host        smtp.gmail.com
      SMTP port        587
  3. Put the password in the environment

    zlib reads the mail password from ZLIB_SMTP_PWD at send time and never writes it to the config file. On Gmail this has to be an App Password, which requires 2-step verification on the account; your normal login password will be rejected by the server.

    $ export ZLIB_SMTP_PWD=your-app-password

    Putting it in your shell profile makes it permanent. Putting it in a .env file next to the project also works, since zlib reads .env from the working directory and from ~/.config/zlib/.

  4. Approve the sender at Amazon

    In your Amazon account, under Manage Your Content and Devices → Preferences → Personal Document Settings, add your From address to the Approved Personal Document E-mail List. Mail from anywhere else is dropped silently, which is the usual reason a send looks like it worked but nothing arrives.

  5. Send something

    Pass a path, or run it bare to get a file picker filtered to the formats Amazon accepts.

    $ zlib kindle send ./dune.epub
      ✓ Sent dune.epub to you@kindle.com
what goes through

Formats and size limits

zlib checks the file before it opens a connection, so a file Amazon would reject fails immediately with a reason instead of vanishing into a mailbox somewhere.

CheckRuleWhy
Extension .epub .pdf .txt .doc .docx .html .htm .rtf .jpg .jpeg .png .bmp .gif Amazon's Send to Kindle accepts these and ignores the rest.
File size 200 MB Amazon's own ceiling for a personal document.
Message size 25 MB, Gmail only Attachments are base64 encoded, which inflates them by about a third, so a 19 MB book becomes a message over Gmail's limit. zlib works this out up front when the host is Gmail.

zlib does not convert between formats. If you need an unsupported format turned into an EPUB first, convert it with something like Calibre and send the result.

--send-to-kindle

Skipping the second command

Every command that ends in a downloaded file takes --send-to-kindle, which mails it on as soon as the download lands. That works on search, download, and history.

$ zlib download 12345678 --send-to-kindle
$ zlib search "the dispossessed" --send-to-kindle
$ zlib history --send-to-kindle

Because none of this needs a terminal UI, the same flags work inside a script or a cron job.

alternatives

How this compares to Calibre

Calibre is the usual answer to this problem and it is a good one. The two tools solve different halves of it, and using both is reasonable.

zlibCalibre
Interface One command, scriptable Desktop app, plus a command-line suite
Format conversion None Extensive, and the main reason to reach for it
Library management None Full catalogue, metadata editing, covers
Mail transport Your SMTP server, configured directly Your SMTP server, configured in preferences
Runs headless Yes, no display needed Yes via calibre-smtp, though the GUI is the common path

The short version: if you need a file converted or a library organised, use Calibre. If the file is already in a format Amazon takes and you want it gone in one line, this is faster.

questions

Common problems

The command reports success but nothing reaches the Kindle.

Almost always the From address is not on Amazon's Approved Personal Document E-mail List. Amazon accepts the mail and discards it without telling the sender, so SMTP reports a clean delivery. Add the address under Personal Document Settings and send again.

Does zlib store my email password?

No. ~/.config/zlib/kindle.json holds the addresses, host, and port only. The password is read from the ZLIB_SMTP_PWD environment variable each time a send runs.

Gmail rejects the login.

Gmail refuses account passwords over SMTP. Turn on 2-step verification, generate an App Password, and use that as ZLIB_SMTP_PWD.

Can I use a provider other than Gmail?

Yes. The host and port are whatever you enter, so any SMTP server works. The 25 MB message check only applies when the host is Gmail; other providers are held to Amazon's 200 MB file limit alone.

Where does the Kindle address come from?

Amazon assigns each device one, ending in @kindle.com. It is listed beside the device under Manage Your Content and Devices.

Get it installed.

Free, MIT licensed, and it only ever talks to Z-Library and the SMTP server you configure.