WordPress.org

Ready to get started?Download WordPress

Forums

HOW TO: Only dispay errors or successful posts when Emailing submissions (1 post)

  1. robspages
    Member
    Posted 6 years ago #

    Exposition:
    WordPress provides a file named wp-mail.php which (in combination with settings in options->writing) allows people to post to their blog(s) by emailing the post to a special email address. Only when wp-mail.php is run does something actually get posted (which is a good thing ®)

    The Caveat:
    In order to fully automate this task you need to use a cron job or some other automation program to call wp-mail.php on a schedule. Several of these programs work well. My web host uses the cURL library and has a handy tool which sends the result of the cURL call to an email address. The email is (unfortunately in my case) required. Every return from cURL will generate an email.

    Since I have curl/wp-mail checking for new messages every 5 minutes, I get a new email every 5 minutes, with or without a post.

    The Solution:
    I have added modified the wp_die call for 'There doesn’t seem to be any new mail' to allow for a variable to be passed in the url which suppresses the page output when there are simply no emails to post:

    if (0 == $count){
    	if(isset($_GET['echoNoneFound']))
    		 die();
    		 }
    		 else{
    		 	wp_die(__('There doesn’t seem to be any new mail.'));
    			}
    }

    The cURL command is:
    curl -s -S http://[yoursite]/[wordPress_install_dir]/wp-mail.php?echoNoneFound=0

Topic Closed

This topic has been closed to new replies.

About this Topic