Useful command for mailhandler default commands

Last modified: March 17, 2009 - 18:50

The "commands" referred to below get put into the Admin->mailhandler->list->Default commands field. A sample of commands that can be used to post incoming emails to a forum would be (including the square brackets):

type: forum
taxonomy: [My Forum]
promote: 0
status: 1

Where [My Forum] is the "term" in the "forums" vocabulary that was automatically created when a forum named "My Forum" was created (see Admin->Categories).

These can be put either on the configuration page for the mailbox, if you want them to be defaults, or at the beginning of the email.

Options

Each option is presented on a separate line in the format key: value, with a single space after the colon.

comment: 2
(0 if no comments, 1 if read-only comments)

format: 1
(To set the input format for your post. Should be numeric. If you've created custom input formats, they are at admin/filters. In the default configuration, 'Filtered HTML' is 1, 'PHP code' is 2, and 'Full HTML' is 3.)

pass: password
(If you required a password on the configuration page, replace password with the correct password.)

promote: 1
(0 if you don't want it promoted)

status: 1
(0 if you don't want it published)

taxonomy: [cat1,cat2]
(Include all tags for your post here, separated by commas. The square brackets are required.)

type: blog
(Provide the node type here. Examples: story, forum, or page. Use type=comment to force a comment. can be used with nid= command)

Also, in the headers of the email, if you put

In-Reply-To: nid=5

then the email becomes the new version of node 5. I'm told that there's a way to take it down to the level of comments, presumably by using In-Reply-To and the comment id#, but I haven't checked that.

Ha-I finally found out..(How to create edit/ nodes and comments)

pasupathymahalingam - June 23, 2006 - 08:04

Hi,

I finally found out how to create and edit nodes and comments. Here is how

To create new node
1. In the 'To' field of the mail
2. In the subject of the mail mention the title of the node getting created
3. Write mail handler commands in the first few lines of the body
4. In the body of the mail write the text of the node

For example if you write in the subject 'test' and in the body of the mail write,

type: page

This is a test node

This will create a node of type page with title 'test' and Body/Text as 'This is a test node'

Note: type: command is required if you have not put it in the default command in the configuration. More over, if type: command is present in the default command in the configuration that takes precedence

To edit node
1. In the 'To' field of the mail
2. In the subject of the mail mention the modified title of the node
3. Write mail handler commands in the first few lines of the body
4. In the body of the mail write the text of the node

For example if you write in the subject 'test - changed' and in the body of the mail write,

nid: 10
type: page

This is a test node which is changed

This will modify the node whose node id is 10 and is of type page with title 'test - changed' and Body/Text as 'This is a test node which is changed'

Note: nid: command is required to identify the node which is getting edited

To add a comment to the node
1. In the 'To' field of the mail
2. In the subject of the mail mention the title of the comment
3. Write mail handler commands in the first few lines of the body
4. In the body of the mail write the comment

For example if you write in the subject 'test comment' and in the body of the mail write,

nid: 10
type: comment

This is a test comment for the test node

This will add a comment to the node whose node id is 10 with title 'test comment' and comment text as 'This is a test comment for the test node'

Note: nid: command is required to identify the node for which the comment is getting added. type: command signifies that a comment is getting added

To edit a comment to the node
1. In the 'To' field of the mail
2. In the subject of the mail mention the modified title of the comment
3. Write mail handler commands in the first few lines of the body
4. In the body of the mail write the comment

For example if you write in the subject 'test comment - changed' and in the body of the mail write,

nid: 10
cid: 5
type: comment

This is a test comment for the test node (This is changed)

This will edit the comment whose id is 5 that is attached to the node whose node id is 10 with comment title 'test comment - changed' and comment text as 'This is a test comment for the test node (This is changed)'

Note: nid: command is required to identify the node for which the comment is getting added. type: command signifies that a comment is getting added. cid: command signifies the comment id that is getting modified

Phoo.... It took me some time to figure out. BTW... I have still not figured out how to reply to a comment!!! Any body who has experimented on this, please reply

Note: default commands (in your mailbox configuration) if any are also taken into account while the mails are processed. If you leave them empty, make sure you add those commands in the first few lines of the mail. More over the commands you specify in the first line gets appended to the default commands. Hence if the default command says type:page and in your mail you say type:story, a page is created and not story!

forum?

echoeng - July 13, 2007 - 16:32

Has anyone figured out how to post to a forum? How did you figure out all of the options? Is there a file or something? Thanks for posting that!

Posting to a Forum

number3 - July 15, 2007 - 22:14

Yup, use the following below in your default commands or in in the first few lines of the e-mail you want to use to generate your content.

type: forum
taxonomy: [insert name of your forum topic]

You can also use the following below to do any specific actions you wish to do.

publish: 1
promote: 1
format: 3
comment: 2

Now, I haven't been able to figure out all the options. I've tried to look for thorough documentation on these options but I haven't found "jack".

And I'm still trying to figure out how to reply to a comment.

Replying to a comment

number3 - July 18, 2007 - 04:40

To reply to a comment

You'll need the following
nid: 29
pid: 9
type: comment

nid is the node id (found in the node table)
pid is the parent comment id that you'd like to reply to (found in the comment table).

managing users - anonymous vs authenticated vs daemons

dman - March 20, 2008 - 04:53

It seems that incoming posts are identified as being owned by the user whose email submitted it. This is all totally clever and intuative, but stumped me for a while when trying to test.

To post to your own site - as you - your email address must be the one registered at the site.

If your site is blocked to anonymous submissions, incoming emails from not-your-email get retrieved ... but go nowhere. An error appears in the watchdog saying something like -
" Mailhandler: The e-mail address 'myemail@gmail.com' may not create mail items."
or (under Organic Groups)
" Mailhandler: Your submission is invalid: title: You must join a group before posting on this web site. "

I didn't have bounce messages on.

I tried making a dummy semi-authenticated account called 'mailer' that was allowed to post, and setting

user: mailer

in the default commands. Didn't seem to help. ... nor
name: mailer

Looking at the code I see that mailhandler_authenticate() just doesn't let this happen. :(

I was about to hack into it to allow $node->name be set ... when I realized what a hole that would be. I'm wanting to set it in the admin (safe) zone, but it gets read from the admin+submitted commands. Meaning it would be pretty easy to spoof. :(

I'm still working on this problem. In the meantime I just added my test-submit account as a user. Maybe I'll have to forward-bounce it or something.
I had to then ensure this user was in the right role to create content etc. Pretty straightforward.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

how about adding content via

mdowsett - December 1, 2008 - 20:01

how about adding content via email into CCk fields in a node...is that possible?

comment command not working?

MashsaM - January 21, 2009 - 17:18

Hi there!

I have drupal 6 and mailhandler is working fine with listhandler to create forum that mirrors a mailing list.

I found the comment command useless. I put it in the default commands and all it does is: all replies coming in by email have the same text in it - "2". That's because I wrote in the default commands "comment: 2". So if I wrote in the default commands "comment: no comments" I would get all comments emailed in with the text "no comments". Confused? me too...

Anyway I'm happy with the forum default settings.

Don't forget the space in your commands

Nathan Gasser - February 5, 2009 - 14:11

Even though all the examples show commands in this format:

promote: 1

I blanked and I omitted the space, like so:

promote:1

Yeah. That won't work.

Don't forget the space. :)

Mail submission to a group

spjsche - May 7, 2009 - 16:03

I have added the following command in the default settings

type: daily_news_report
og_groups: [2]
promote: 1
status: 1

to mark the post to a specfic group, but it does not work - or have I done it wrong.

Any help would be appreciated.

Thanks

Please read the code in mailhander.module

Gowri - May 13, 2009 - 04:09

This will not work according to the code. But it is a good idea extend to og group postings. The type can be either node or comment. But the code seems simple enough to understand and customize.

There is a function mailhandler_node_submit. This function you may want to customize to post to a specific og group.

Hope it helps.

Thanks for the pointer, I

spjsche - May 13, 2009 - 14:33

Thanks for the pointer, I will endeavour to review the function and see
if I can customize it for my needs.

Thanks
Stephen

@spjsche have you found

GregoryHeller - May 20, 2009 - 06:36

@spjsche have you found anything out about this? I have a similar requirement: sending email to create a new node within a specific group. I was thinking another way to go might be creating different mailhandler email addresses for each group, though not sure how well that scales. It would still need something that does not exist, like a "og_mailhandler" module that lets you assign a particular mailhandler for each og

Check this out =>

spjsche - June 11, 2009 - 16:05

Check this out => http://drupal.org/project/mail2og

Thanks
Stephen

Owww yeah .... just what i

Lenn-art - June 12, 2009 - 12:08

Owww yeah .... just what i needed!

mailhandler_node_submit() is

kentr - June 26, 2009 - 20:39

mailhandler_node_submit() is in mailhandler.retrieve.inc.

In case anyone's looking for it...

Drupal forum-email integration reply-to address not working

keeline - June 19, 2009 - 23:28

I have a Drupal 6 installation on a Linux server with postfix (smtp) and dovecot (imap) installed and working properly. I would like to integrate forums with email so that a message sent into the list address is added to the forum and subscribers to the forum receive emails to which they can reply and continue the forum thread.

The primary modules I am using for this task are forums, subscriptions, mailhandler, and listhandler. Here is what works:

* I can send an email (from an account with an existing Drupal user account) to the mailing list address defined in mailhandler and the message is received by smtp and handed over to the imap mailbox. At the cron interval the mailbox is checked by mailhandler and processed and posted to the forum (as a new message each time).

* Users who subscribe to the forum are sent a copy of the posted email by mailhandler + subscriptions.

Here is what does not work:

* The email message is From: the original sender. That is OK. However, when I hit "reply" in Outlook, it tries to reply to the original sender instead of the mailing list address.

It seems as if it should be possible to set the Reply-to: address for the email to be the list address if desired. However, I cannot find a suitable input for this in the admin form nor in the code for the two modules (mailhandler and listhandler).

I think what I am trying to do is possible and should be something others would also care to do. It would help facilitate forum usage by people in front of their computers and using mobile phones with an email option (e.g. iPhone).

I have tried various values in the mailhandler Default commands configuration but I have not come up with a working solution. Here is the most basic Default commands setting:

tid: 8
status: 1

I have tried setting the From header address to either the list address or "From: " followed by the list address. I have also tried to use commands like "user: ", "name: ", "From: ", "from: ", and so on without success.

Where can I find a list online or on my site of all of the commands which can be used in this Default commands field?

Also, since each message sent to the list address starts a new forum post, we don't get any reply threading which would be nice. I guess that the commands can be placed in the body of the email for processing to attach it to the node with the right type but we would prefer if this was an automatic rather than a manual procedure. Is there any help for this?

I've been working through all I can find on drupal.org and other resources for quite some time and hope that a developer or user can help. I've used PHP for 10 years and Drupal for 2.5 years plus we have a couple other Drupal guys working with us but we have not been able to come up with an answer thus far.

James

@keeline: Check out these modules for "reply to" functionality

kentr - June 27, 2009 - 06:02

@keeline: Check out this module for "reply to" functionality

http://drupal.org/project/mail2web

Odd that listhandler isn't working. It claims to do what you want, from what I can tell.

I have not used either of these. I also need this functionality and would like to hear of your results.

 
 

Drupal is a registered trademark of Dries Buytaert.