HowTo – Posting To Your WordPress Blog By EMail

Filed under: Wordpress Tips

wordpress-logoWordPress has a great built in editor and dashboard but sometimes you will be away from your computer for a long period of time and really need to get a post out.

Well lucky for us WordPress has a built in mail function that will let you grab email from your email server and then convert it into a post. Unfortunately there are a few drawbacks from using this method and there are some additional steps that you must take to automate the process.

The first consideration is spam

Everyone gets spam .. we get it on public accounts like Hotmail and Gmail and we get it on private accounts that we setup on our own servers even when we do not announce the email address to the world.

Because of this it is important that you use a email account user name that is not easily guessed… similar to your passwords the email user name should be random characters. WordPress will even suggest an appropriate email user name when you are setting up the email feature.

For instance … browse to your WordPress Writing Options and in the Email Publishing settings you will see a paragraph above the settings boxes that suggests a few random strings for the user name … Here are three random strings you could use: lwJVKWRZ, EsaHVWNZ, WEdYcKUt

This is basically security through obscurity but it is a decent way to get started.

To use such an email address you want to place the account on your own domain. You can also setup a number of email filters to reject email from anyone that is not suppose to be posting to your wordpress account.

If you do not take all these steps you risk having your WordPress site publish all of the spam you get and this can be an annoyance that will probably make you stop using the feature.

Configuring Your WordPress Writing Settings

Once you have your email address and account setup ready you can fill in the rest of the information that WordPress needs to access your Email Account.

Like configuring any email reader you will need your

Server Address and Port Number
User Name
Password

Category
And you can also setup which category on your site that your Email Posts should be added to.

Testing Your Email To Post Settings

Once you have completed the basic setup you can test if your configuration works by sending a test email to your email account.

After you have sent the Email you will need to open a special WordPress page on your site to activate the process of checking for mail and converting to posts.

Browse to : www.yoursite.com/wordpresslocation/wp-mail.php

You should then see a dialog of how the process completed. If there are errors shown then make corrections to your settings and try again until the process is working and you get posts publishing on your site.

You will need to do this every time you send an email but there are ways to automate this process.

Automating the WordPress Email Publishing Process

Now that you know your settings are working you can automate the process of checking for email by setting up a cron job.

If you have access to your server then you can simply setup CURL or WGET to read the wp-mail.php file every 15 minutes or an hour.

If you are on a shared hosting account then you can setup a cron job within cPanel or through another interface that your administrator provides.

If for some reason you do not have access to setting up cron jobs then you can install a plugin for wordpress that can process the cron tasks. wp-cron is one such plugin.

Another method is to setup a hidden IFRAME on your front page that will read in the wp-mail.php file every time one of your visitors hits your homepage.  I do not like this idea because it exposes the fact that your site is using wordpress email publishing features…

A better way would even be to simply place a PHP curl event at the very  bottom of your pages and read it into a var and maybe update a database setting with the last time it was run sucessfuly.

That is beyond the scope of this howto but not hard to do.

Unfortunately putting a curl or iframe request on each of your pages or in a home.php theme template could have your administrator screaming their head off if your site gets any volume of traffic.

It is much better to use a Cron Job that is timed to at least 1 hour.

Final Note

This is not the most difficult thing to setup but remember that you will be limited to plain text in your emails when generating posts…. or at least you are at the time of this writing..

For this reason you may not get all the value of publishing from within the WordPress editor but it will still keep you connected to your readers when you are away.

Make sure you setup good email filters on your email account to reduce the possibility of spam getting posted.