How to post to your WordPress blog using email

This is a pretty cool feature of WordPress, something I’ve come to love. In fact, this very post was posted via email! There are a few steps to setting it up, which may seem daunting when you look at it, but don’t worry, it’s really quite simple!

There are basically 3 steps you need to follow:

  • Enter settings that will allow WordPress to access your e-mail messages
  • Create an e-mail account that will be used only for the purpose of posting to your blog
  • Tell WordPress to grab the emails and turn them into posts

The first and second steps can be done in any order, but I would suggest doing it in the order outlined above. One thing to consider is that you will need an email account that offers you POP3 access.

The first step, entering settings that will allow WordPress to access your email messages, is easy.

  • Log in to WordPress using your administrator account
  • Go to Options > Writing
  • Look under the Post via e-mail section. WordPress will suggest 3 randomly generated strings. You should pick one of these as your email name, or make up one on your own that is hard to guess. You DO NOT want others to know about this email address or they could post garbage to your site. Now enter the POP3 access information you will use for your email account. If you don’t know what to enter for the mail server you should get that information from your
    email provider, or you can try something like mail.youremaildomain.com, since this is a common configuration. Leaving the port at 110 is also likely to work, but if it doesn’t you will need to get that information from your email provider.

The second step is to create your email account. Just be sure to use the same name and password you entered in the WordPress settings.

The third step has several options.

The easiest, although not the most convenient, is to go to a web page on your site at http://yourdomain.com/installdir/wp-mail.php where installdir is the directory WordPress is located (It may be in the root of your website, which would mean you would enter no directory at all). Visiting this web page will tell WordPress to grab all emails from your email account, turn them into posts, and publish them immediately.

The next option is to add the following iframe tag to the footer of your WordPress blog:

<iframe src="http://yourblogdomain/wordpressinstalldir/wp-content/plugins/postie/get_mail.php?Submit=Run+Postie" name="mailiframe" width="0" height="0" frameborder="0" scrolling="no" title=""> </iframe>

This causes WordPress to check for new emails with every page visit. Because it checks every time it might be a little more of a burden on your email and web server, especially if you have a lot of traffic.

The last option (my favorite and the one I use) is to set up a cron job to executes that web page for you, at a time or on an interval that you define. For example, you might have it check your email every 10 or 15 minutes. If you have the ability to set up cron jobs you could execute several types of commands, but here are two simple
ones to choose from:

wget -N http://example.com/installdir/wp-mail.php
php /full/path/to/wp-mail.php

or

php5 /full/path/to/wp-mail.php

if you are running PHP version 5

There are a couple plugins out there that can mimic the behavior of a cron job as well, such as WP-Cron

And that’s all there is to it! Not too bad, and when you have it set up you’ll be sooo glad you did. Enjoy!