I didn't find it possible to interact with the sender's mail address on hook_nodeapi, since it doesn't seem to be saved anywhere. So when I have given the anonymous users the right to post nodes via mail, there's no way to see on the node what was the sender's e-mail address - at least I didn't find it.
How I made it possible for my purpose:
1. on the mailhandler_node_submit() right before the line $node = node_submit($node); I added a line $node->fromaddress = $fromaddress;
2. created a cck field called "sender"
3. on my own module I implemented the hook_nodeapi() and there saved the mailhandler-created fromaddress to the "sender" field with line $node->field_sender[0]['value'] = $node->fromaddress;
Would you see this as something that should be done in future versions?
Comments
Comment #1
z.stolar commentedYou could use hook_mailhandler for that purpose. It would be much simpler and natural.
You might also want to take a look at that: http://drupal.org/node/310100 and see where that develops to.
As for adding it to mailhandler in the future: The main issue of course is - where would you keep this address, and what will you do with it. I never tried to allow anonymous users the permission to send mails, but I do see your point.
I think the optimal solution in this case would be to write a module (I don't know of any existing one) that, for each anonymous node. holds an email as an identifier. This module can implement the mailhandler hook, and retrieve the necessary information.
Comment #2
tormu commentedOk great, this solves my problem completely!
I wasn't aware of that hook at all :)
I've got a custom module of my own that contains other functions for the site too, so just adding a implementation for that like below solved it.
PS. There's a reference for the $node as the parameter (&$node), but if there's no return $node statement at the end, it doesn't work - isn't this kind of wrong in some way? If there's no return value, the mailhandler says at the retrive-phase that it has received message(s) successfully, gives no errors, but doesn't actually create the nodes at all. Adding the return $node at the end makes it work though.
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.