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 converter into thinking that there are no attachments. (These
emails are interpreted correctly by pretty much everything 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 probably several ways to fix this, but I fixed it by creating a
new version of Zend_Mail_Transport_Smtp
:
class Zend_Mail_Transport_Smtp_Kindle extends Zend_Mail_Transport_Smtp
{
protected function _prepareHeaders($headers)
{
// Remove some headers from the mail enclosure--these somehow confuse
// Amazon's Kindle converter, leading it to conclude 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)) {
unset($headers["Content-Transfer-Encoding"]);
}
if (array_key_exists("Content-Disposition", $headers)) {
unset($headers["Content-Disposition"]);
}
return parent::_prepareHeaders($headers);
}
}
Anyway, with this “bug” worked around, I can now do this:
My ~/Library/PDF Services/Send to Kindle
reads:
#!/bin/bash
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 Workflow Options in the Print Dialog” for more information.)