Post By Email Update: Horde library!

After much wailing and gnashing of teeth, I was finally able to get the Post By Email pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the Plugin Directory or can be cost-based plugin from a third-party working against the Horde IMAP Client Library.

It’s a bit of a hack right now — I still need to clean up the code and pull a lot of it out into helper functions — but with this in place, I’ve laid the groundwork for supporting SSLSSL Secure Sockets Layer. Provides a secure means of sending data over the internet. Used for authenticated and private actions. and IMAP connections (without requiring PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher to be compiled with IMAP support).

A couple of technical oddities…

  • The Horde framework is massive, and while the IMAP library is available as a standalone PEAR package, it still has a ton of dependencies to the rest of Horde.  I solved the problem in a quick-and-dirty way by copying any missing files into the plugin’s includes directory.  Horde uses an autoloader to include the classes it needs; I’m planning to experiment with that, but for now I just wrote a wrapper (so I only have to include one file in the plugin class).  (Does anyone know whether autoloading plays nicely with WP?)
  • Instead of copying over the translationtranslation The process (or result) of changing text, words, and display formatting to support another language. Also see localization, internationalization. classes, I stubbed out one of them in a “bogus” way that uses WP’s translation functions instead.  Might poke around and see whether I can do this with any of the others, as well.

The good news is that, once I got this working, I was able to scrap the whole preexisting deal with reading each message line by line and processing it with (buggy) regexes… and move to letting Horde abstract parsing out headers, decoding MIME, etc.  This will also make it much easier to deal with HTMLHTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers. emails, attachments, and so on in the future.

For now it still supports only POP3, but unlike the previous iteration, it doesn’t lose all the text and create blank posts — certainly an improvement.  🙂

Next steps: Refactor check_email into helper functions and add support for IMAP, then SSL connections.

#post-by-email, #weekly-update