HAYCORN — 5 February 2011

ZendMail and Amazon's Kindle Converter

If you’re trying to use Zend_Mail to send email to Amazon’s free PDF-to-Kindle converter, you might like to know that for some reason two headers that Zend_Mail adds to the message—Content-Transfer-Encoding and Content-Disposition—trick Amazon’s con­verter into think­ing that there are no attachments. (These emails are in­ter­preted cor­rectly by pretty much every­thing else as far as I can tell so I’m not sure if this is Zend_Mail’s fault, or Amazon’s, or both.)

There’s prob­a­bly several ways to fix this, but I fixed it by cre­at­ing a new version of Zend_Mail_Transport_Smtp:

class Zend_­Mail_­Trans­port_Smt­p_Kin­dle extends Zend_­Mail_­Trans­port_Smtp
 pro­tected func­tion _prepareHeaders($headers)
 // Remove some headers from the mail enclosure--these somehow confuse
 // Amazon's Kindle converter, leading it to con­clude that there are
 // no attachments. (Even though every other mail client seems to be
 // able to cope.)

 if (array_key_exists("Content-Transfer-Encoding", $headers)) {
 if (array_key_exists("Content-Disposition", $headers)) {

 return parent::_prepareHeaders($headers);

Anyway, with this “bug” worked around, I can now do this:

OS X print dialog, with Send to Kindle option
OS X print dialog, with “Send to Kindle” option

My ~/Library/PDF Services/Send to Kindle reads:


TITLE=$(perl -MURI::Escape -e 'print uri_escape(join(" ", @ARGV))' $1)

cat "$3" | curl --data-binary @- "http://beebo.org/api/kindle/?username=ithinkihaveacat&title=$TITLE"

(See “Providing PDF Work­flow Options in the Print Dialog” for more information.)