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_email_reject_recipients | 1.8.8 | This filter is called before a reject notification is sent and can be used to modify the recipient list. |
postie_email_notify_recipients | 1.8.8 | This filter is called before a success notification is sent and can be used to modify the recipient list. |
postie_email_reject_subject | 1.8.8 | This filter is called before a reject notification is sent and can be used to modify the subject line. |
postie_email_notify_subject | 1.8.8 | This filter is called before a success notification is sent and can be used to modify the subject line. |
postie_email_reject_body | 1.8.8 | This filter is called before a reject notification is sent and can be used to modify the message body. |
postie_email_notify_body | 1.8.8 | This filter is called before a success notification is sent and can be used to modify the message body. |
postie_place_media | 1.8.10 | This filter is called when replacing the #img# with an actual image reference and can be used to modify the html fragment. |
postie_place_media_before | 1.8.10 | This filter is called after the image/audio/video/attachment template has been filled out and the “Image Location” setting is “Before”. |
postie_place_media_after | 1.8.10 | This filter is called after the image/audio/video/attachment template has been filled out and the “Image Location” setting is “After”. |
postie_raw | 1.8.27 | This action is called when the email is retrieved from the email server. |
postie_bare_link | 1.8.31 | This 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_category | 1.8.32 | This filter is called after the category is found in the subject line. |
postie_file_added_pre | 1.9.1 | This action is called before the attachment is added to WordPress. |
postie_include_attachment | 1.9.13 | This filter is called to determine if the file should be added |
postie_parent_post | 1.9.28 | This filter is called to determine the post ID that should be the parent of this post. |
postie_register_shortcode_pre | 1.9.44 | This action is called to allow you to register any Postie specific shortcodes. |
postie_subject | 1.9.53 | This filter is called to determine the subject (post title). |