Sélectionner une page

How To Post By Email With WordPress

How To Post By Email With WordPress

What if you wanted to post something to your WordPress site, but you didn’t have the time, or you didn’t want to take the time, to go to your site? Easy! Write a blog post in your email and send it to your site. WordPress will post it for you!

Being able to post from email means you can post from anywhere without having to log into your website. You only need access to your email account. This is a great way to publish from a smartphone that doesn’t have the WordPress app installed.

What an amazing feature, right? There are several ways you can post from email. Let’s take a look at how it’s done.

Post via E-mail

How to Use the WordPress Post by Email Feature - Post via E-mail

This is the email feature built into WordPress. To use this you have to set up a secret email account that you send your posts to. Anything that gets sent to that email account gets posted to WordPress. Of course you don’t want anything and everything being posted to WordPress that you or a team member didn’t write, so you’ll have to create an email account that has a high level of privacy. Keep it secret; keep it safe.

To create a secret email, WordPress recommends using random strings in the email address. It gives you three suggestions that are randomly generated. This email needs POP3 access. Anything posted from the email account will be posted in a single category that you set as its default category.

The folks at WordPress feel that this feature is outdated so it will be removed in an upcoming WordPress release. This is now old news and it stills remains intact in the current version. However, it will eventually be removed. When it is, there will still be several methods to make it work. One option is calling the function in code. Another, of course, is plugins. Let’s take a look at our options.


An alternative to calling wp-mail.php directly is to use a method to trigger it. Most of the plugins for posting by mail will do this for you. However, if you still want to do this manually, here is the method that WordPress recommends.

Action Based

You can add an action to you theme’s function.php code that will check for an email every 15 minutes. This code will run when the pages are loaded, so it’s dependent on your site’s traffic. Here’s the code:

add_action( 'shutdown', 'retrieve_post_via_mail' );
function retrieve_post_via_mail() {
	flush(); // Display the page before the mail fetching begins
	if ( get_transient( 'retrieve_post_via_mail' ) ) {
		return; // The mail has been checked recently; don't check again
	} else { // The mail has not been checked in more than 15 minutes
		do_action( 'wp-mail.php' );
		set_transient( 'retrieve_post_via_mail', 1, 15 * MINUTE_IN_SECONDS ); // check again in 15 minutes.

You can change the timing by changing the “15” within set_transient to anything you want. If you do, just make sure you change the comments to match (this will help you avoid confusion later – just trust me on this). If you don’t want it to be dependent on your site’s traffic you can use cron jobs.

Cron Jobs

Cron jobs are configured in the server and they run independent of your site’s traffic. First you have to activate the cron job.


There are several ways to activate the cron job for UNIX. One way is to use the wget, curl, or GET command from the command line. The code would look like this:

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

Substitute wget and its arguments with the program you use.

Another option is to run the php script within a cron job. It would look like this:

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

This is probably a better choice as php doesn’t require special authorization to run, where wget probably will.


If the host is run on Windows you can use a program that is similar to running a cron. Some good choices are:

Each contains documentation on running the cron.

Activating Procmail

If you’re using procmail then you would use .procmailrc in the blogmailaccounts home directory:

| wget -N http://example.com/installdir/wp-mail.php

You could even use specific subject expressions if you want. There is more info about this at the procmail site.

Activating .qmail

You can set up servers that use .qmail to call wp-mail.php any time an email is delivered. First you would create a shell-script to call wp-mail.php. The script would look like this:

/bin/sh -c "sleep 5; /path/to/php /path/to/your/blog/wp-mail.php > /dev/null" &

This would go in your root directory, and the execute bit should be set (chmod 700).

Next you need to create the .qmail file to call your shell script. Add this line of code to the .qmail file for your mailbox name:


Naming conventions will vary from one ISP to another, so you’ll have to consult your ISP’s documentation for more information about .qmail files.

Now, if you don’t want to get into all of that code, you can use a plugin.


WordPress recommends that you use a plugin to post from email. They recommend Post by Email, Jetpack, or Postie. Here is a quick look at these plugins and how to use them.


How to Use the WordPress Post by Email Feature - Jetpack

If you’re not using Jetpack, well… you should be using Jetpack. Jetpack is a free suite of plugins from Automattic (those WordPress creators) that has plenty of essential plugins that are lightweight and add value rather than bloat. Among its many tools is a feature to post from a secret email account.

This one creates an email address when you enable the post by email feature (it’s not enabled by default). This is the address you will send your emails to. The address can be changed if you ever need to. Just go back to the button where you enabled the feature and click Regenerate Address. I think it has unlimited regenerations (I always wanted unlimited regenerations).

Developing the post is simple. It uses the subject line as the post title. It will keep as much of the formatting as possible, so you can use HTML if your email client uses rich text or HTML formatting. You can also send plain text if you don’t want to specify any formatting. You can post from any email client. Note – If you’re using a web-based client such as Hotmail or Gmail, or a desktop based system such as Outlook, then you already have a rich text formatting mode.

The post will automatically remove the signatures from clients such as Hotmail and Gmail, and anything after the <hr/> HTML tag for cellphone networks. You can also use a shortcode within your email to remove any unwanted signatures.

There are plenty of other shortcodes that you can embed within your email to format your post. You can use them to:

  • Choose the category
  • Choose tags
  • Set an excerpt
  • Set a more tag
  • Delay the publishing by one hour
  • Turn comments on and off
  • Set the published status (published, pending, or draft)
  • Setup a slideshow
  • Turn the gallery off (the gallery is automatically turned on by default)
  • Set publicize options (it will send notifications to both Facebook and Twitter)
  • Set up a poll for Polldaddy
  • Next page
  • Slug
  • Title (if you want to specify something other than the email title)

You can include images as attachments. A single image will be displayed inline. Multiple images will automatically be set as a gallery unless you provide a shortcode to remove the gallery. This is a superfast way to create a gallery. Simply take a ton of photos and attach them to an email. Done. And easy.

Jetpack is super easy to use, but I have a few issues with it. First, only one address is provided. This is great for one person, but what if you have a team with each member having their own account? This means that every email sent will automatically be labeled as being posted by the administrator.

Second, only one social network can be used with Publicize if you post each network in a separate shortcode. You can send it to both Facebook and Twitter in a single shortcode, but you can’t use separate shortcodes. Why do I care about this? I might want to use templates for my email with shortcodes already posted. This just means I have to use more than one template or I have to include all of the shortcodes and pay close attention to which shortcodes to delete. If I didn’t this would reduce the functionality of Jetpack and take away one of the advantages of Publicize. It’s easy enough to make it work correctly, but it is something to be aware of.

Still, these issues are not enough to keep me from using it. This is a great way to create a full-featured post from your email account. The shortcodes and HTML functions ensure that the posts will look great on your site and not look like you created them in an email.


How to Use the WordPress Post by Email Feature - Postie

This free plugin gives you lots of advanced features over the current default feature that’s built into WordPress. There are lots of good features that allow you to format your posts including the title, category, status, post type, tags, excerpt, HTML, gallery, comment control, remove headers and footers from the email, etc.

What this one adds are some of the things that are missing in the Jetpack plugin. For one, you can control who gets to post by email. You select which roles are allowed to post. All roles are choices – from administrator all the way to subscriber. You can also tell it which address are authorized to send a post. So if you have more than one person that posts on your site, the post will be labeled with their name. You can allow anyone to post if you want (I seriously have no idea why you would want to do this). For unregistered users you can choose which administrator name you want to use as the default poster. Yeah, I’m not recommending this feature, but it’s there if you want it.

You can set it to automatically take the first image from the post and set it as the featured image. There are templates for images, video, audio files, and other attachments. Email replies become comments.

You can choose how often you want it to check for emails to post. You can choose every 5 minutes, 10 minutes, 30 minutes, hourly, daily, weekly, or only manually.

This one is easy to set up and use, but you do have to set up a lot of options. It’s nowhere near as easy to use as Jetpack, but it has so many more features that it’s worth it. You’ll have to set up your mail protocol (It supports POP3 and IMAP, and you can use SSL or TSL), port, server, ID’s, etc., and then you can make all of your choices for default categories, etc. It has a dashboard where you can make all of your adjustments, too. It is highly customizable.

There are add-ons that expand it even further. Most add-ons are $29 and include:

  • Clean HTML (ensures W3C compliance)
  • Polylang (multiple language support)
  • Geolocation Plus (you add latitude and longitude)
  • Image Only (this one is $5)
  • Open Street Maps (you add a latitude and longitude and it does the rest)

Post by Email

How to Use the WordPress Post by Email Feature - Post by Email

This free plugin is currently in beta and hasn’t been updated in a while, but I installed it on the latest version of WordPress and ran it with no trouble. However, being in beta means you might run into compatibility issues, so run it at your own risk.

You set up an email address to send posts from, and any email it receives from that address gets posted. This is an address you’ll want to keep secret.

It has similar features to what we’ve seen in the previous two plugins:

  • Supports IMAP and POP3, with or without SSL
  • PIN-based authentication guards against email spoofing
  • Uses roles to manage who can post
  • Shortcodes in your email will set categories, tags, and custom taxonomies
  • Attachments are automatically added to the post’s gallery

Any email that it receives from an unauthorized user will be set as pending or you can set them to be discarded if you prefer.

This one is easier to set up than Postie, but only because there are fewer choices to make. It gives you an activity log so you can track attempts to post, etc.

A Couple of Tips

When posting from a secret email account you are running the risk of anyone being able to post to your blog. It is crucial that you keep this email account a highly guarded secret. Only log into this email account on computers you trust. Log out when you’re not using the email.

Use an email template with all of your preferred shortcodes already setup. Then, you only have to update the text and images in order to create a new post.

Wrapping Up

Well, there you have it. Posting to WordPress through email is a handy feature. I can see how this could save lots of time or make it easy to post when you’re away from your favorite computer chair. All three plugins are good choices and posting with them can greatly simplify your posting while on the go.

Your turn! Do you post to your WordPress website through email? Do you have a different method, or have you used a different plugin than what I described here? I’d like to hear your thoughts in the comments below!

Article thumbnail image by Studio_G / shutterstock.com

Source link

Poster le commentaire

Votre adresse e-mail ne sera pas publiée.