• Resolved gizmomol

    (@gizmomol)


    Thanks for continuing to develop Postie, a very useful plugin.

    I would like Postie to ignore any email received with “Automatic reply:” in the subject.

    I have tried various postieFilter functions but all my attempts have resulted in two posts, “tmpFile” and “tmptitle”.

    Is there a Postie option or filter to ignore a post based on subject?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Wayne Allen

    (@wayneallen-1)

    There is nothing built in. It shouldn’t be too difficult in a filter. Can you post what you tried?

    Thread Starter gizmomol

    (@gizmomol)

    I have a ‘postie_post_before’ filter like the code below:

    add_filter('postie_post_before', 'filter_title'); 
    
    function filter_title($post) {
       if (substr($post['post_title'], 0, 16) == 'Automatic reply:') {
           return null;
       }
       return $post;
    }
    Plugin Author Wayne Allen

    (@wayneallen-1)

    It is possible the category logic is altering the post title before postie_post_before sees it. Try setting “Use colon to match category” to no.

    See https://postieplugin.com/faq/override-post-categories/ for background.

    Thread Starter gizmomol

    (@gizmomol)

    Thanks, I checked and see all the Postie category options are already set to “No”.

    Thread Starter gizmomol

    (@gizmomol)

    The ‘postie_post_before’ filter, as above, did cause a result, just not the ignore result I hoped for.

    Instead of completely ignoring the email, it left the two temporary Postie files “tmpFile” and “tmptitle”.

    Plugin Author Wayne Allen

    (@wayneallen-1)

    It shouldn’t. That should only happen if there problem. Can you click the debug button when one of those emails in waiting and email the output to [email protected]

    Thread Starter gizmomol

    (@gizmomol)

    I just sent it.

    Thanks

    Thread Starter gizmomol

    (@gizmomol)

    I have three “postie_post_before” filters enabled. I discovered that when I moved the above “filter_title” function last, it discards the “Automatic reply” email.

    So when a filter makes the $POST null, it can cause any following filters to misbehave.

    Is it wrong to return null? I suppose all filters should check if $POST is null first before doing anything.

    Plugin Author Wayne Allen

    (@wayneallen-1)

    Returning null is the correct thing to do. However, I do see this in the log:

    Post postie_post filter
    Array
    (
        [post_content] => <br/>
        [post_category] => Array
            (
            )
    
    )
    

    This shows what is in $post after the postie_post_before filter, as you can see it is not null. I suspect you have another Postie addon installed, is that true?

    Thread Starter gizmomol

    (@gizmomol)

    I have three “postie_post_before” filters in filterPostie.php.

    Today, I added a test for an empty $post array at the beginning of all three filters which return null if empty.

    There were some conditions where I added the ‘<br/>’ tag at the end of the content in two of these filters. Updated to only add the tag if content is not empty.

    For the specific problem of “Automated reply:”, the debug output for “Post postie_post filter” is:
    Post postie_post filter
    postie_post filter cleared the post, not saving.
    Done

    I believe this solved my support question.

    Thanks for your support

    Plugin Author Wayne Allen

    (@wayneallen-1)

    Glad you got it sorted!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Discard “Automatic reply:”’ is closed to new replies.