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 nameVersion first availableNotes
postie_filter_email1.5This 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_email21.6.3This filter is called after postie_filter_email and includes the “To” and “Reply-To” fields.
postie_filter_email31.7.28This filter is called after postie_filter_email2 and includes all email headers.
postie_author1.6.3This filter is called after the WordPress user has been identified.
postie_post_before1.5.14This filter is called just before Postie saves the post. Replaces postie_post.
postie_post_after1.5.14This action is called just after Postie saves the post.
postie_file_added1.7.0This action is called after an attachment is successfully inserted and associated with the post.
postie_gallery1.7.2This 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_before1.7.6This filter is called just before Postie saves a comment. Requires that the “Treat Replies As” setting is set to “comments”
postie_comment_after1.7.6This filter is called just after Postie saves a comment. Requires that the “Treat Replies As” setting is set to “comments”
postie_category_default1.7.8This filter is called to determine the default category.
postie_log_debug1.7.17This action is called at various times with debug logging info.
postie_log_error1.7.17This action is called if there is an error.
postie_session_start1.7.20This action is called each time a Postie session starts (i.e. every 10 minutes)
postie_session_end1.7.20This action is called at the end of each Postie session.
postie_preconnect1.7.26This filter is called just before Postie attempts to connect to the email server.
postie_post_pre1.8.1This filter is called before postie_post_before and before Postie has made any changes.
postie_email_reject_recipients1.8.8This filter is called before a reject notification is sent and can be used to modify the recipient list.
postie_email_notify_recipients1.8.8This filter is called before a success notification is sent and can be used to modify the recipient list.
postie_email_reject_subject1.8.8This filter is called before a reject notification is sent and can be used to modify the subject line.
postie_email_notify_subject1.8.8This filter is called before a success notification is sent and can be used to modify the subject line.
postie_email_reject_body1.8.8This filter is called before a reject notification is sent and can be used to modify the message body.
postie_email_notify_body1.8.8This filter is called before a success notification is sent and can be used to modify the message body.
postie_place_media1.8.10This filter is called when replacing the #img# with an actual image reference and can be used to modify the html fragment.
postie_place_media_before1.8.10This filter is called after the image/audio/video/attachment template has been filled out and the “Image Location” setting is “Before”.
postie_place_media_after1.8.10This filter is called after the image/audio/video/attachment template has been filled out and the “Image Location” setting is “After”.
postie_raw1.8.27This action is called when the email is retrieved from the email server.
postie_bare_link1.8.31This filter is called when a “bare” link is detected and before it is inserted and gives you a chance to augment/change the resulting markup.
postie_category1.8.32This filter is called after the category is found in the subject line.
postie_file_added_pre1.9.1This action is called before the attachment is added to WordPress.
postie_include_attachment1.9.13This filter is called to determine if the file should be added
postie_parent_post1.9.28This filter is called to determine the post ID that should be the parent of this post.
postie_register_shortcode_pre1.9.44This action is called to allow you to register any Postie specific shortcodes.
postie_subject1.9.53This filter is called to determine the subject (post title).