Generate new post from email

WordPress doesn’t provide any built-in endpoint or API to handle incoming mail and parse it into a action.

So I see 3 possible options:

  • Use a existing mail parser for WordPress and figure out a way to run a action
  • Configure email inbox on your server and pipe incoming emails to a script to be able to parse it using a PHP parser like mailparse and then send a request to custom endpoint to perform the location update operation
  • Use a Post to WordPress plugin like Postie to be able to post to a CPT and hook into the post creation process to update the location.

A bit of explanation here:

You’d need to develop the whole thing on your own or use one of the existing integrations like Zapier and WordPress which can probably server the purpose with a bit of modifications: https://zapier.com/apps/email-parser/integrations/wordpress ( I’ve never used any of those so I’m not sure how good it is.)

If you rather prefer to develop it on your own this thread here is of particularly great help: https://stackoverflow.com/questions/7541278/how-do-i-parse-emails-in-realtime-as-they-are-recieved

Basically you’d need to pipe the incoming mails to a script which then uses a PHP extension like mailparse to read necessary details from the email and send a request to WordPress REST API endpoint or calls a custom Ajax action.

This is definitely going to be a decent amount of work since I don’t see existing implementations similar to this.

There are some plugins that allows you to posts to WordPress via email, postie plugin seems to be promising for your purpose to be able to modify it in some way to make it post to a CPT and then hook into the create post for that CPT to be able to update the location.