Send books to Kindle from the terminal. 在终端里把书发到 Kindle。

One command mails a file through your own mail server. 一条命令,通过你自己的邮件服务器发送文件。

zlib kindle send ./dune.epub

Needs zlib. Install it. 需要先安装 zlib。查看安装方式

Set it up once.设置一次就好。

  1. Configure delivery配置发送

    Answer the form.按提示填写表单。

    $ zlib kindle config
    
      Kindle address   you@kindle.com
      From address     you@gmail.com
      SMTP host        smtp.gmail.com
      SMTP port        587
      SMTP security    (empty follows the port)(留空则按端口选择)
  2. Set the password设置密码

    Gmail needs an app password.Gmail 需使用应用专用密码。

    $ export ZLIB_SMTP_PWD=your-app-password
  3. Approve the sender认可发件人

    At Amazon, add your From address to the Approved Personal Document E-mail List. 在亚马逊把你的发件地址加入“已认可的发件人电子邮箱列表”。

  4. Send发送

    Run zlib kindle bare for a file picker. 不带参数运行 zlib kindle,可从列表中选择文件。

    $ zlib kindle send ./dune.epub
    ✓ Email sent to Kindle address: you@kindle.com
    → Final delivery depends on Amazon approval and file compatibility.

Know the limits.了解限制。

Check检查项 Limit限制
Extension扩展名 .epub .pdf .txt .doc .docx .html .htm .rtf .jpg .jpeg .png .bmp .gif
File size文件大小 200 MB
Message size邮件大小 25 MB on Gmail Gmail 上限 25 MB

zlib checks before it connects, and it does not convert formats. zlib 会在连接服务器前检查,不转换格式。

Send as it downloads.下载完就发送。

Add --send-to-kindle to download, history, search, favorites, recommended, or most-popular. 下载时加上 --send-to-kindle 即可发送,download、history、search、favorites、recommended 和 most-popular 都支持。

$ zlib download 12345678:a1b2c3 --send-to-kindle
$ zlib history -D 12345678:a1b2c3 --send-to-kindle
$ zlib search --send-to-kindle

With an ID they run in scripts, as long as ZLIB_SMTP_PWD is set. 指定 ID 时可在脚本中运行,前提是已设置 ZLIB_SMTP_PWD。

Common problems.常见问题。

It says sent, but nothing arrives.显示已发送,但 Kindle 没有收到。

The From address is not on Amazon’s approved list. Amazon drops the mail without telling the sender. Add the address and send again. 发件地址不在亚马逊的认可列表中。亚马逊会直接丢弃这类邮件,且不会通知发件人。把地址加入列表后重新发送即可。

Does zlib store my password?zlib 会保存我的密码吗?

Not in kindle.json. It reads ZLIB_SMTP_PWD on each send. The terminal prompt saves it to ~/.config/zlib/.env. 密码不会写入 kindle.json,每次发送时从 ZLIB_SMTP_PWD 读取。在终端界面中输入的密码会保存到 ~/.config/zlib/.env。

Gmail says a 19 MB book is too big.19 MB 的书,Gmail 却说太大?

Base64 adds a third, so a 19 MB book is already over Gmail’s 25 MB. Base64 编码会让体积增加约三分之一,所以 19 MB 的书就已超过 Gmail 的 25 MB 上限。

Can I use another provider?可以用其他邮箱吗?

Yes, any SMTP server. The 25 MB check applies only to Gmail. 可以,任何 SMTP 服务器都支持。25 MB 的检查仅针对 Gmail。

Where is my Kindle address?在哪里找到 Kindle 地址?

It ends in @kindle.com, under Manage Your Content and Devices, beside the device. 地址以 @kindle.com 结尾,在亚马逊“管理我的内容和设备”中,列在对应设备旁。

Get zlib.获取 zlib。

Free and MIT licensed. It connects only to Z-Library, your SMTP server, and GitHub for updates. 免费,采用 MIT 许可证。只连接 Z-Library、你的 SMTP 服务器,以及检查更新用的 GitHub。