Mailhandler commands system (1.x)
How command processing works - technical overview
A command consists of two main parts - a key and a value. In the command type: blog "type" is the key and "blog" is the value. There is explicit handling for commands related to taxonomy. Apart from taxonomy, there is general handling for properties on the node object. For example, commands are searched for and collected on an incoming message. If the command is specific to taxonomy, it will be processed according to the parameters explained in the "Taxonomy commands" section below. If the command is not related to taxonomy, the property on the $node object with the name "key" will get set with its corresponding value. For example $node->type = 'blog' would get executed if the command type: blog is found. Therefore, if you're using another module which owns a property on the node object, you can see how you could assign a value to that property by specifying the name of the property and a value in your mailhandler commands.
List of known mailhandler commands
Node settings commands
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/settings/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)
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)
sticky: 1
Set whether the node is sticky
language: nl
Taxonomy commands
taxonomy: [term1, term2]
Use this to add the terms term1 and term2 to the node. Both of the terms should already exist. In case they do not exist already, they will be quietly ommitted. Brackets are required.
taxonomy[v]: [term1, term2]
Similar to the above: adds the terms term1 and term2 to the node, but uses the vocabulary with the vocabulary id v. For example taxonomy[3] will choose only terms from the vocabulary which id is 3. In case some of the terms do not exist already, the behavior will depend on whether the vocabulary is a free tagging vocabulary or not. If it is a free tagging vocabulary, the term will be added, otherwise, it will be quietly ommitted. Brackets are required.
Node and comment defaults
When defaults for settings like whether a node should be published or promoted to the front page are not defined in commands, the defaults on /admin/content/node-type/%node-type (where %node-type is the real name of a node type on your site) defined for that node type will be used. If you are posting a comment via mailhandler and you do not specify default published status in your commands, the permission system will be used. For example, if a user with only the 'authenticated user' role posts a comment via mailhandler and the 'authenticated user' role has the permission 'post comments without approval" then the comment will get posted in a published state. If the user does not have the permission "post comments without approval" then the comment will get posted in an unpublished state.
Examples
Posting to forum
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.
Post a comment to an existing node
type: comment
nid: 54
A new comment will be created on node 54.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion