Note: this is only applicable to Mailhandler versions 6.x-1.x and 7.x-1.x (colloquially "Mailhandler 1.x"). For a tutorial on setting up a more complex post-by-email system and mailing list (which could integrate with a forum or case tracker), using Mailhandler 2.x, see the article Setting up an email-driven workflow with attachments

How to submit Blog post by Email Note, my experiences are for simple email processing. I haven't done anything like tying an email list to a forum.

Step 1: Turn on the mailhandler module

Admin -> Modules
Click on the module

Step 2: Set up an email account to which you will send email

This depends on what you are using for a mail hosting service. I use cpanel, click on Mail , click on Manage/Add/Remove accounts.. Click on Add accounts and set up the email address and the password. For my system, the email can be retrieved as POP3. Again, this depends on the mail hosting service you are using.

Step 3: Configure the mailhandler

Admin -> Mailhandler
Click on Add Mailbox, fill in the appropriate fields.

Email address
Use the email address you set up in step 2 e.g. incoming@example.com. (I have not used the Second email address for my purposes.) In most cases, using INBOX and POP3 for the folder and Mailbox settings should work, again, it depends on your mail service.

Mailbox domain
Should be the domain that you are using. e.g. example.com

Mailbox port
Again, the default of 110 should work, depending on your hosting service.

Mailbox username and password:
Use the userid and password from Step 2, or whatever has been assigned for the email address.

Extra commands
Extra parameters to send with imap_open() for certain mail servers that require certain parameters. For example, warning: imap_open() [function.imap-open]: Couldn't open stream -- this warning requires Extra commands to have: /novalidate-cert/tls

Mime preference
I always simply use HTML. Your choice. Not a biggie.

Security
I leave this disabled. I believe there is enough security with the mail handler as it is. If you do enable it be sure not to use the HTML mime preference.

Send error replies
I like to enable this and leave it enabled, unless I am tying somehow to a mailing list. Even if I am doing that, I would initially have send error replies on until I am sure things are doing what I want.

From header
Again, for personal mail handling, I leave this blank. As noted, you may want to use Sender for mailing lists.

Default commands
This is where I end up doing most of my tweaking. Currently, as an example, I use
type: page
taxonomy: [mail]
promote: 1
format: 3

type: page causes the posts to be page entries. You can also use blog, story, forum, etc.

taxonomy: [mail] I have a taxonomy term called mail for all posts coming in via email. This can be omitted if you don't want to place the entries into a taxonomy category

promote: 1 For the site I'm using, I want email entries to be promoted to the front page. If you don't want them promoted to the front page, omit this line

format: 3 This is my latest tweak to get it so the posts are processed as Full HTML instead of filtered HTML. If you are going to receive HTML email, you really should have this on.

Signature Separator: I leave this blank. This is probably most useful for mail coming from a mailing list that appends some signature stuff, or if you have your own signature file.

Delete Messages after they are processed: Yup. I do that. I don't want the mail box filling up with messages that have already been processed.

cron processing: I generally leave this on.

Step 4: Testing Mail Sending

Once you have the account set up, send an email to the account. Be sure to send it from an email address that has a userid on your site. Otherwise you will get a message something like:

The e-mail address 'tester@example.com' may not create page items.
You sent:
From: tester@example.com

Step 5: Testing the mail retrieval

When the mail has been sent, go to:
Admin -> Mailhandler

You should see the email address under the list. Click on 'retrieve' next to the email address. If everything is working properly, you should get a message something like:

Mailhandler retrieve successful: 1 messages for incoming@example.com

You should then be able to go to and find the message that you submitted at:
Admin -> Content

Assuming this is running properly, all you need to do is make sure that cron is running regularly and emails will be processed as they are received.

Comments

Mike Sances’s picture

Thanks for this how-to, this seems really useful! However, assuming you set up your site to automatically receive e-mails from certain e-mails--what's to stop a hacker or spammer from filling out an "Email this page" form on another site (e.g. boston.com or idealist.org) and putting the e-mail address of one of your users as their return address? Wouldn't that allow them to get their content on the site without a password? I know when I use those "Email this page" forms to send things to myself, they appear just as if they come from the return address.

mattcbaker’s picture

Firstly, there are a lot easier ways of sending email "From" specific email addresses - you don't need to use online forms.

Secondly, in order for content to be posted, you need to have knowledge of both the "From" and "To" addresses, which means you need to know:
a) the email address to send posts to (which may or may not be public knowledge - on my site only a few people know this)
b) the email address of a site user with the correct privileges to be able to post content (users email addresses aren't generally made public)

This level of security is good enough for me, but if you are concerned about people guessing / finding out the email addresses then either:
a) Switch on the "require password" option
b) Wait until it becomes a problem, and then switch on the password option.

so4’s picture

mailhandler is working fine for me, thank you for this module.

Is there a possibility that a user can register an alternative e-mail for sending messages? Most of my users don't have a fancy device with Internet, there sending message via sms/mms and the sender e-mail is specific to the device.

Any hint?

tarsem12s’s picture

i got this error plz Help

warning: imap_open() [function.imap-open]: Couldn't open stream

tarsem12s’s picture

i got this error plz Help

warning: imap_open() [function.imap-open]: Couldn't open stream...

asanchez75’s picture

Maybe you must put the all username, for example: username@midominio.org

Dave Hirschman’s picture

This is working for an incoming email account at 1and1.com:

E-mail address: incoming@your1and1domain.com
Folder: INBOX
POP3 or IMAP Mailbox: POP3 (although imap would probably work fine as well)
Mailbox domain: pop.1and1.com
Mailbox port: 110
Mailbox username: must be exactly the same as "E-mail address"
Mailbox password: password for incoming@your1and1domain.com
Extra commands: leave blank

I think that "Mailbox domain" should really say "POP3 or IMAP server."

a_c_m’s picture

try putting

/notls

into the extra commands section.

scifisi’s picture

Yikes! I think this is a cool module, all the tests are sucessfull and I also get the message:

Mailhandler retrieve successful: 1 messages for post@mydomain.com

The only trouble I have is that I just don't get any content added to my site - doh!

Any ideas what I'm not doing?

many thanks :)

scifisi’s picture

I'm using these commands:

type:story
promote:1
status:1
comment:2
format:1
moderate:0

scifisi’s picture

The support around here is great, you can wait for 1 and a half YEARS and noone will reply with an answer:

So in classic fashion I will answer my own question having found the answer to what could otherwise have been answered by most drupalers....

No content from this module will work - Unless you allow your users POST Story/Node writes...

Goto Administer > User Management > Permissions

About halfway down the page under the heading Node Module you will see create story content

This MUST be enabled before ANY content will be posted from this module.

ceefour’s picture

Your solution for Node Module permission will certainly help us (and me too).

It's users like you what makes a community great :)

swatee_karpe’s picture

Hi

I am using Mailhandler 6.x-1.8 module.

When i set the mailbox,and send mail to that email id, and after click on that retrieve link on that drupal site where we set the mail box

then it will give me following error:

Parse error: syntax error, unexpected '=', expecting ')' in /hsphere/local/home/amrutequ/equestind.com/indug_mail/sites/all/modules/mailhandler/mailhandler.retrieve.inc on line 625

This 625 line contains function call as follows:
function mailhandler_retrieve_message(&$result = FALSE, $mailbox, $i, &$context) {

Please help me for resolve this error.

Why this error are coming?
Is my mistake or modules mistake....

System6Hosting’s picture

I want to use this to send posts from a cell phone. It's working fine using text messages. What I really want though is to send images. When I try it goes to white screen of death after retrieving, then reloading page gives a bunch of errors mostly relating to bad arrays and improper data types. The Drupal log entries have many many pages of errors. So I'm assuming that this module just can't handle images right now? Or is there some special setup I've missed? Thanks.

Road Runner’s picture

I have been screwing around with it for a couple of hours until I got it to work.
You need a CCK image field set to accept file extensions jpg gif png add them to list separated by space. Add this CCK field to content type you want to create from your mofile device.

In mail handler config select the content type from the list of content types you have on your site - radio button so only one allowed.

FYI, It seems you can only upload one image per email.

wwwoliondorcom’s picture

Hi,

I can't make it work, and I get the message "Unable to connect".

I am using Dreamhost, any help ?

Thank you.

cor3huis’s picture

Dreamhost settings as of 20101221:

STEP 1) If you just created this emailaddress wait at least 5 minutes before you can use this emailaddress

STEP 2) Set all these values, but use your real users and domains ofcourse...

E-mail address: youremail@yourdomainname.com
Folder: INBOX
POP3 or IMAP Mailbox: IMAP
Mailbox domain: mail.yourdomainname.com
Mailbox port: 143
The port of the mailbox used to collect mail (usually 110 for POP3, 143 for IMAP).
Mailbox username: youremail@yourdomainname.com (INCLUSIVE the part behind the @ !)
Mailbox password: yourpass
Extra commands: /notls
MIME preference: text
Default commands: tid 1 (Can be differend, read mailhandler documention)
Cron processing: Disabled
Message authentication method: Mailhandler Default

STEP 3)
Click [save mailbox]

STEP 4)
Click [test mailbox]

STEP 5) On overview page of Mailhandler
Click [Retrieve]

wait for mail to get in...

BTW question like this better asked in Drupal Forum

fehin’s picture

subscribing

remedios’s picture

Hello,

I was getting "warning: cannot open stream" error. For me, the error was fixed by listing "localhost" as the Mailbox Domain in step 3.

In step 3, it says:
Mailbox domain
Should be the domain that you are using. e.g. example.com

I think it could be helpful to add a "specify localhost if mail server is the same as your web server" line.

The settings that worked were:

E-mail address: USER@MYDOMAIN.org
Folder: INBOX
POP3
Mailbox Domain: localhost
Mailbox port: 110
Mailbox Username: USER@MYDOMAIN.org
Mailbox Password: PASSWORD
Extra commands: /novalidate-cert/tls
MIME Preference: HTML
Security: Require password
[etc]

My old settings were:

E-mail address: USER@MYDOMAIN.org
Folder: INBOX
POP3
Mailbox Domain: mail.MYDOMAIN.org
Mailbox port: 110
Mailbox Username: USER@MYDOMAIN.org
Mailbox Password: PASSWORD
Extra commands: /novalidate-cert/tls
MIME Preference: HTML
Security: Require password
[etc]