Skip to content

Uses IMAP to check a mailbox, converts HTML newsletter emails to PDFs and sends them to Amazon Kindle email address

License

Notifications You must be signed in to change notification settings

alexpcooper/newsletters-to-kindle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Newsletters to Kindle

Uses IMAP to check a mailbox, converts HTML newsletter emails to PDFs and sends them to an Amazon Kindle email address

Latest Stable Version Total Downloads License

Process

  1. Checks a folder in an email inbox, via IMAP
  2. Collects the email and converts it into a PDF
  3. Sends the PDF to Amazon, to convert into an ePub format and place in your Amazon Kindle library
  4. Deletes the email

Installation

Official installation method is via composer and its packagist package alexpcooper/newsletters-to-kindle.

$ composer require alexpcooper/newsletters-to-kindle

Usage

<?php

require_once __DIR__ . '/vendor/autoload.php';

$newsletter2kindle = new newsletters2kindle();
$newsletter2kindle->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();

Debug

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

Parameters

Parameter Explanation
kindle_email Used to send the PDF email to, so that it goes to your Amazon account
imap settings 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
imap_dir This can be your inbox or a subfolder, eg. "Inbox", "[Gmail]/All Mail", "my-newsletters", etc.
debug Prints out progress or any issues as it goes; for debugging only (defaults to false)
delete_mail_after Keeps the mail in the mailbox after processing (defaults to true) - note that subsequent requests will pick up the same email again

Included Packages

With thanks to the following for these dependancies;

Requirements

  • php's IMAP library (eg. extension=imap.so) needs to be enabled in your php.ini file

Troubleshooting

Known Issues

  • 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.

About

Uses IMAP to check a mailbox, converts HTML newsletter emails to PDFs and sends them to Amazon Kindle email address

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages