Support » Fixing WordPress » EMail-to-post: how to strip out signature block?

  • One of the sites that I help manage uses WordPress along with a mailing list app called PHPList. I setup an EMail-to-post address in WordPress and subscribed that address to the appropriate mailing list – so there’s a WordPress category that acts as an archive for the mailing list messages.

    The mailing list messages include a signature block, however, with various links (unsubscribe, view your preferences, etc). What I’m looking for is some automatic way to strip that text out, before the content of the EMail gets posted to WordPress.

    I tried the “Postie” plugin and a few other hacked versions of wp-mail.php, but they either didn’t work – or worked, but caused other problems.

    I’m thinking that the simplest solution would be to just add some php code into wp-mail.php to look for the signature delimiter (five dashes in this case, —–) and strip out all the text from that point on. But I haven’t been able to figure out how to do that so far.

    Does anyone have recommendations for code that would accomplish removing the signature, and/or where the code should go in the wp-mail.php file?

Viewing 1 replies (of 1 total)
  • It’s a kludgy hack, but this worked for me:

    In wp-mail.php:


    // Captures any text in the body after $phone_delim as the body
            $content = explode($phone_delim, $content);
            $content[1] ? $content = $content[1] : $content = $content[0];
            $content = trim($content);


    if ( strpos(" " . $content,"#END#") > 0 ) {
              $content = substr($content,0,strpos($content,"#END#"));


    $post_content = apply_filters('phone_content', $content);
            $post_title = xmlrpc_getposttitle($content);

    Then when you email a post, just include “#END#” (without the quotes) at the end of the post content. Everything after #END# will be removed.

    You could use “—–“, “Free stuff for your email! Click here” or anything else, if you want. Just make sure whatever you use will not appear in a desired location in your emailed post.

    Obviously, this assumes that you have the ability to modify the sent email, or at least can find a consistent sig in it.

    BTW, I realize the if… logic could be simplified to a single line, but I was trying for clarity, not code brevity.

Viewing 1 replies (of 1 total)
  • The topic ‘EMail-to-post: how to strip out signature block?’ is closed to new replies.