I'm using mailhandler in conjunction with several modules that use the mailhandler hook to process incoming messages.

If none of my modules process the message, I would like mailhandler to ignore the node (rather than attempt to post it as a blog post).

The attached diffs allow users to configure each mailbox with the default node type they would like un-handled messages to be posted as (or optionally set to none, in which case mailhandler will ignore the node).

Comments

cor3huis’s picture

Category: feature » task
Status: Active » Needs review

Looks like a valid improvement also for higher versions. So if someone can test it on 5.x and it works we could see to make it a feature request

ilo’s picture

From my understanding, if your hook_mailhandler() implementation returns NULL, no node or comment is saved at all. Please, review the mailhandler.module file, and search for something like this (it is in 6.x-1.x-dev, but I have no idea when this was introduced)

 // modules may override node elements before submitting. they do so by returning the node.
  foreach (module_list() as $name) {
    if (module_hook($name, 'mailhandler')) {
      $function = $name .'_mailhandler';
      if (!($node = $function($node, $result, $i, $header, $mailbox))) {
        // Exit if a module has handled the submitted data.
        break;
      }
    }
  }

  if ($node) {
    if ($node->type == 'comment') {
      $nid = mailhandler_comment_submit($node, $header, $mailbox, $origbody);
      $type = 'comment';
    }
    else {
      $nid = mailhandler_node_submit($node, $header, $mailbox, $origbody);
      $type = 'node';
    }
  }
ilo’s picture

Status: Needs review » Closed (works as designed)

Well, actually, as this is already fixed in the 6.x version, there is nothing more to do here!