Set up Mailhandler on Drupal 7 to post content by email
Follow these steps to set up your Drupal build to accept content by email.
Step 1 - Download and upload the following modules
- Feeds - Link
- Job Scheduler - Link
- Most importantly, Mailhandler - Link (In alpha stage when I wrote this post)
Step 2 - Enable these modules
Step 3 - Set up mailbox
On the control panel that you use, in my case cPanel, set up a new mailbox that you will be sending content TO. Take care to note the username and password of your new mailbox.
Step 4 - Add a mailhandler mailbox
Go to admin/structure/mailhandler/add and create a new mailbox. Use the details of the mailbox that you just set up from your control panel. The image below is an example of what the settings should look like.
Step 5 - Test mailbox
Save this mailbox setup and now go to your email account which you will be sending content from. In my case I will send from my Hotmail account. Create a test email with a title and body text and set the TO address to the email address which you set up. E.g firstname.lastname@example.org. Send this email and then return to your mailbox configuration. At the bottom of the config page, click on Test and Save and you should receive a green Drupal message saying that there is one email in the inbox. Please note that this method will only work when you send the content email FROM the email address that the site settings is registered to.
Step 6 - Set up feed importer
Go to admin/structure/feeds/create and enter a useful description for your importer.
Step 7 - Use the following details to set up your importer
Please note that if you are receiving errors about missing plugins, you simply need to flush the cache tables on Drupal a couple of times. This worked for me. Use the details below to set up your importer:
Basic settings - Add a description but otherwise, leave as it is. You can increase the refresh time if you wish but we will run this on cron anyway.
Fetcher - Set to mailhandler fetcher and in the settings set "Nodes Only"
Parser - Set to IMAP stream parser and in the settings, remove files processor unless you wish to be attaching documents with your emails. Otherwise leave as it is.
Set the processor to "Node processor" and set the settings for this tab to however you want the importer to work. You have the option to set the content type of the imported email. In my case I set this to blog post and I also set the text format to filter the HTML coming in. I found, with this turned off, I would get some badly formatted text in the title of my blog post.
The final setting is to set the mapping of the variables. Click on "Mapping" and assign the correct variables to the correct content fields. In my case I simply added subject -> Node title and body -> Body.
Step 8 - Set up CRON
Go to admin/config/system/cron and make sure that cron is running in the time frames you wish. Run a test cron job and you should receive a message saying that "1 node has been imported".