Home / functions.php / Post to your blog using email
  • How to Post to your blog using email


    Place this snippet in the functions.php of your wordpress theme. This snippet will check every 15 minutes for new emails within the account you specify and post them. The Subject of your email will be the title and text placed within the body of your email for the post content.

    ( click code to copy )

    wordpress snippet : PHP

    add_action('shutdown', 'retrieve_post_via_mail');
    function retrieve_post_via_mail() {
    	if(get_transient('retrieve_post_via_mail')) {
    	} else {
    		$mail = wp_remote_get(get_bloginfo('wpurl').'/wp-mail.php');
    		if(!is_wp_error($mail)) {
    			set_transient('retrieve_post_via_mail', 1, 60 * 15);
    		} else {
    			set_transient('retrieve_post_via_mail', 1, 60 * 5);

    ( WordPress codex functions, hooks, in this snippet. )

    bloginfo, shutdown, wp_remote_get, add_action, _e, get_bloginfo, is_wp_error, wp,
  • excuse me sir. is it email from contact info (profile) or in general setting that this snippet would check? sorry about my english and this probably silly question. :)

  • oh. so stupid of me. it would be email address in ‘Post via e-mail’ in writing section isn’t sir? so sorry to bother you. have a nice day :)

    • Yes it is the email in the settings post via email. If you have any questions please feel free to ask.