en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en es de en en de en de en de en de en de de en en en fr fr ja es es fr sv en en en en en en en en en en en en en en en vi en en en kn az en en en en en en en vi en en en en en en en en en en en en en en en en en en en en id en en en
Uses IMAP to check a mailbox, converts HTML newsletter emails to PDFs and sends them to Amazon Kindle email address
Last update: 2022-09-16 21:02:22 UTC
Checks a folder in an email inbox, via IMAP
Collects the email and converts it into a PDF
Sends the PDF to Amazon, to convert into an ePub format and place in your Amazon Kindle library
Official installation method is via composer and its packagist package alexpcooper/newsletters-to-kindle.
$ composer require alexpcooper/newsletters-to-kindle
kindle_email = 'your-kindle-email@kindle.com'; $newsletter2kindle->imap_email = 'your-email@address.com'; $newsletter2kindle->imap_user = 'your-email@address.com'; $newsletter2kindle->imap_pass = 'emailpassword'; $newsletter2kindle->imap_host = 'imap.host.com'; $newsletter2kindle->imap_port = 993; $newsletter2kindle->imap_dir = 'Inbox'; $newsletter2kindle->checkMail();
As the process of sending an email to a 3rd party (Amazon) is "fire and forget", without any confirmation or failure, there are two optional parameters, in the event of needing to troubleshoot.
Add one or both of these prior to calling checkMail().
$newsletter2kindle->debug = true; // false by default or when not specified $newsletter2kindle->delete_mail_after = false; // true by default or when not specified
Used to send the PDF email to, so that it goes to your Amazon account
Used to both check an email directory, such as your inbox, for an email to convert, as well as to send the PDF to Amazon as the FROM address
This can be your inbox or a subfolder, eg. "Inbox", "[Gmail]/All Mail", "my-newsletters", etc.
Prints out progress or any issues as it goes; for debugging only (defaults to false)
Keeps the mail in the mailbox after processing (defaults to true) - note that subsequent requests will pick up the same email again
With thanks to the following for these dependancies;
php's IMAP library (eg. extension=imap.so) needs to be enabled in your php.ini file
Ensure that your "kindle_email" address is correct as it appears on your Amazon account for receiving documents (see Edit Your Send to Kindle Email Address)
Ensure that your sending email address is permitted to send documents to your Amazon Kindle (see Add an Email Address to Receive Documents in Your Kindle Library)
Due to the composition of emails, occasionally a block of style tags may be printed onto the end document. This is caused by external sources, such as includes / images, being pulled in after the email is parsed.
At present the Kindle document appears in Amazon without an Author being populated, even though it's on the PDF. This seems to be caused on Amazon's side, when they convert the document.