Extending

Postie uses standard WordPress “filter hooks” during the processing of each email to give you a chance to do some special processing.

Not a programmer? I do custom development and can help you. Contact me

Getting started

First we need to glue Postie and your custom code together.

The simplest way is to create a file named filterPostie.php in the wp-content directory and place the following code into it. Postie will automatically recognize this file so you don’t have to do anything else.

<?php 
function my_postie_post_function($post) {
    //do something here like update $post['post_content']
    return $post;
}

add_filter('postie_post_before', 'my_postie_post_function');

?>

This is the minimum code you need to write. In this case my_postie_post_function() dosen’t actually do anything.

Alternatively you can do all this in your theme or plugin.

Debugging

You can call ErrorEcho(), DebugEcho() and DebugDump() to output information. EchoError and DebugError take strings as parameters. DebugDump can take any object.

You can also create a folder called “test_emails” in the postie folder. Postie will then put raw and parsed versions of each email it receives in the folder. This is useful if you need to see the internal structure of the emails.

Filters

Filter hook name Version first available Notes
postie_filter_email 1.5 This filter is called after the "from" email address has been extracted from the email so that you have a chance to change who is the author.
postie_filter_email2 1.6.3 This filter is called after postie_filter_email and includes the "To" and "Reply-To" fields.
postie_filter_email3 1.7.28 This filter is called after postie_filter_email2 and includes all email headers.
postie_author 1.6.3 This filter is called after the WordPress user has been identified.
postie_post_before 1.5.14 This filter is called just before Postie saves the post. Replaces postie_post.
postie_post_after 1.5.14 This action is called just after Postie saves the post.
postie_file_added 1.7.0 This action is called after an attachment is successfully inserted and associated with the post.
postie_gallery 1.7.2 This filter is called when Postie inserts a gallery shortcode into the post (which only ever happens if the "Automatically insert image gallery" setting is turned on). You can use this filter to generate an alternate gallery shortcode.
postie_comment_before 1.7.6 This filter is called just before Postie saves a comment. Requires that the "Treat Replies As" setting is set to "comments"
postie_comment_after 1.7.6 This filter is called just after Postie saves a comment. Requires that the "Treat Replies As" setting is set to "comments"
postie_category_default 1.7.8 This filter is called to determine the default category.
postie_log_debug 1.7.17 This action is called at various times with debug logging info.
postie_log_error 1.7.17 This action is called if there is an error.
postie_session_start 1.7.20 This action is called each time a Postie session starts (i.e. every 10 minutes)
postie_session_end 1.7.20 This action is called at the end of each Postie session.
postie_preconnect 1.7.26 This filter is called just before Postie attempts to connect to the email server.
postie_post_pre 1.8.1 This filter is called before postie_post_before and before Postie has made any changes.
postie_post 1.4 This filter is called just before Postie saves the post. Deprecated in favor of postie_post_before as of 1.5.14.