Hi. I want to get mailhandler and listhandler functional for 4.7. I use Apache2 , Mysql 4.1 . I'm new to Drupal. My site needs these badly. For me, these seem to be very close to functioning. I've searched and can not find any recent activity on these . I'm posting here in hopes of someone already having patches for these or is working on this and could use help or having good advice or wanting to help.

Mailhandler is giving me the same problem discussed here: http://drupal.org/node/32805 -- that is that when it creates a new forum topic from an email, it does not link them to the parent forum in the term_node table. This causes the new topic not to be listed in the Forum. Other that that, it appears to work beautifully. I posted a bug report in 4.7 forum.module for this since that is where the 4.6 report was posted.

Listhandler from cvs worked for a while and then retrievals started dieing and logging me out at the same time, ultimately ending up in a white screen. Disabling listhandler made retrievals work again. I am not sure what is involved in porting to 4.7 from 4.6 however seeing as it worked for a while, it is probably pretty close already.

Thanks and cheers,

Comments

pjsz’s picture

Simple patch does 3 things. I looked at doing it via a hook in forum but that will have to wait for this newbie. It seems much should be factored out of mailhandler and delegated to other modules. Since that probably wont happen soon, i just put it in mailhandler.

My understanding of forum system is limited and these patches are based on that. However i tried to limit their influence the best I could. Testing of these is limited to a few hours and a single system. Here is what this patch does

  1. Makes it so forum topics made by email are visible in the Forums. It creates a term_node row *ONLY* if the type is "forum" and it is creating and not updating. It does not alter term_node upon update via email. I hope i never do that anyway.
  2. For some reason it was setting comment bodies to the value of the comment setting as made by the mailhandler command (node and comments tables "column" column do two different things). In my case it was "2" every time for Read/Write comments. This patches that also.
  3. I wanted to be able to have more than one signature separator. I tweaked it to do that by delimiting with '|'.

    cheers,

    --- mailhandler/mailhandler.module.4.7  Tue Jul 18 18:21:36 2006
    +++ mailhandler/mailhandler.module      Tue Jul 18 18:43:51 2006
    @@ -102,7 +102,10 @@
      */
     function mailhandler_comment_submit($node, $header, $mailbox, $origbody) {
       if (!$node->subject) $node->subject = $node->title;
    -  if (!$node->comment) $node->comment = $node->body;
    +  // We dont want the node's comment setting to be the body of the comment.
    +  if (!$node->comment or preg_match('/^\d$/', $node->comment))
    +               $node->comment = $node->body;
    +
       // We want the comment to have the email time, not the current time
       $node->timestamp = $node->created;
       // comment_save gets an array
    @@ -132,6 +135,7 @@
       $node->revision = in_array('revision', $node_blog_default);
       $node->comment = variable_get('comment_blog', 2);
    
    +
     function mailhandler_node_submit($node, $header, $mailbox, $origbody) {
    
       $fromaddress = mailhandler_get_fromaddress($header, $mailbox);
    @@ -156,6 +160,10 @@
         else {
           if (node_access('create', $node)) {
             node_save($node);
    +                               if ($node->type == 'forum') {
    +                                       mailhandler_term_node_insert($node);
    +               watchdog('special', t("Mailhandler: Added term node for new forum topic"));
    +                               }
             watchdog('special', t("Mailhandler: Added '%t' by %f", array('%t' => $node->title, '%f' => $fromaddress)));
           }
           else {
    @@ -182,6 +190,14 @@
     }
    
     /**
    + * Insert the term_node so that topics show up in forum listing
    + *
    + */
    +function mailhandler_term_node_insert($node) {
    +       db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $node->tid);
    +}
    +
    +/**
      * Append default commands. Separate commands from body. Strip signature.
      * Return a node object.
      */
    @@ -189,7 +205,7 @@
       $node = new stdClass();
    
       // initialize params
    -  $sep = $mailbox['sigseparator'];
    +  $separators = explode('|', $mailbox['sigseparator']);
    
       // copy any name/value pairs from In-Reply-To or References e-mail headers to $node. Useful for maintaining threading info.
       if ($header->references) {
    @@ -243,10 +259,15 @@
         }
    
         // stop when we encounter the sig. we'll discard all remaining text.
    -    $start = substr($line, 0, strlen($sep)+3);
    -    if ($sep && strstr($start, $sep)) { // mail clients sometimes prefix replies with ' >'
    -      break;
    -    }
    +    $found_sig = false;
    +    foreach ($separators as $sep) {
    +       $start = substr($line, 0, strlen($sep)+3);
    +       if ($sep && strstr($start, $sep)) { // mail clients sometimes prefix replies with ' >'
    +                       $found_sig = true;
    +               break;
    +       }
    +       }
    +       if ($found_sig) break;
       }
    
       // isolate the body from the commands and the sig
    @@ -597,7 +618,7 @@
       $form['replies'] = array('#type' => 'radios', '#title' => t('Send error replies'), '#options' => array(t('Disabled'), t('Enabled')), '#default_value' => $edit['replies'], '#description' => t('Send helpful replies to all unsuccessful e-mail submissions. Consider disabling when a listserv posts to this mailbox.'));
       $form['fromheader'] = array('#type' => 'textfield', '#title' => t('From header'), '#default_value' => $edit['fromheader'], '#description' => t('Use this e-mail header to determine the author of the resulting node. Admins usually leave this field blank (thus using the <strong>From</strong> header), but <strong>Sender</strong> is also useful when working with listservs.'));
       $form['commands'] = array('#type' => 'textarea', '#title' => t('Default commands'), '#default_value' => $edit['commands'], '#description' => t('A set of commands which are added to each message. One command per line. See %link.', array('%link' => l(t('Commands'), 'admin/help/mailhandler/#commands'))));
    -  $form['sigseparator'] = array('#type' => 'textfield', '#title' => t('Signature separator'), '#default_value' => $edit['sigseparator'], '#description' => t('All text after this string will be discarded. A typical value is <strong>"-- "</strong> that is two dashes followed by a blank in an otherwise empty line. Leave blank to include signature text in nodes.'));
    +  $form['sigseparator'] = array('#type' => 'textfield', '#title' => t('Signature separators. Delimit with \'|\' '), '#default_value' => $edit['sigseparator'], '#description' => t('All text after these strings will be discarded. Leave blank to include signature text in nodes. A typical value is <strong>"-- "</strong> that is two dashes followed by a blank in an otherwise empty line. Add as many as you want with a \'|\' and no spaces separating them. <strong>"------------------"</strong> could be one way to strip the signature from a mailing list.'));
       $form['delete_after_read'] = array('#type' => 'checkbox', '#title' => t('Delete messages after they are processed?'), '#default_value' => $edit['delete_after_read'], '#description' => t('Uncheck this box to leave read messages in the mailbox. They will not be processed again unless they become marked as unread.'));
       $form['enabled'] = array('#type' => 'radios', '#title' => t('Cron processing'), '#options' => array(t('Disabled'), t('Enabled')), '#default_value' => $edit['enabled'], '#description' => t('Select disable to temporarily stop cron processing for this mailbox.'));
    
pjsz’s picture

Listhandler worked for first few hours today. Then a mailhandler retrieve caused a white screen and for me to be logged out. I disabled and reenabled listhandler, and it works again. I am not really sure what listhandler is doing mingling with mailhandler retrieve. I thought perhaps it happened after cron was run. So i ran cron and then retrieved. Listhandler still worked.

Another thing i noticed is long subject lines to emails get posted as topics to forums. However when you comment on them via drupal, leaving the subject line blank and thus unchanged, only the first word seems to get sent as the subject. This starts a new thread in gmail. However, threading is maintained in the forum :)

cheers

pjsz’s picture

Correction to correction -- it seems that the first comment on a topic takes the first phrase from comment body and puts it as the subject if subject is blank. Then any comments on that comment take the subject of that comment. Weird. Anyway, listhandler does it differently so it gets rather inconsistent. Thats ok.

I believe all this is not accurate anymore:
A topic created by email with first word ALL caps like this comment's subject has an intersting property. Its comments's subjects will get trimmed of everything but that first all CAPS word (when subject field left blank and you expect it to have the whole subject of parent). Weird. I created a topic in DRUPAL and it works as expected. Hmm. Factor could be the "[mailinglistname]" part of the subject. Testing .... Nope. Comments for topics created in drupal behave normally it appears -- that is they maintain the complete subject of the parent unless it is changed by the author. Hmm. Testing CAPS word in middle ...

pjsz’s picture

Listhandler CVS version was updated a week or so ago that fixes 2 problems with 4.7 . Yeahh! Thank you. http://drupal.org/node/74358

One of the problems and the problem causing it to die on mail retrievals was it was still using the 4.6 method "_user_authenticated_id()" instead of the constant DRUPAL_AUTHENTICATED_RID .

pathscollide’s picture

I also desperately need these two modules for my 4.7 site. It looks like Mailhandler has an official release for 4.7. Listhandler doesn't yet but it looks like people are working on it. Is there anything like a timeline when this will be ready for an official release?

Thanks to those who are working on this.

mrchristian’s picture

Hi,

I've been using mailhandler and listhandler on a site http://metamute.org since jan 2006 but im now facing the issue of installing the same system on Drupal 4.7 and as people mentioned above listhandler doesnt seem available yet.

When its up and running it would be great to hear about it.

Many thanks

Simon

http://metamute.org/ - culture and politics after the net

pjsz’s picture

Hi. i'm not the developer of listhandler. I'm just a person who needs it too. I'm back at work now. AFIK , listhandler seems to work pretty decent except for one thing -- It always creates an account for every non known user. Ie, spammers get accounts on my site and their messages are getting posted to the forum. I see a setting for "blocked" or "active" account status. How about a "none" option so NO account is created ? Mailhandler does a fine job of ignoring messages not from members. Anyone else have this problem? I'm looking into that now.
Or perhaps it is something that can be set up with the mailing list and mailbox? Ie, tell the mailbox to only accept messages from the mailing list ?

cheers

pjsz’s picture

My list mailbox has a setting to file messages based on subject to a particular folder. It uses IMAP to do this. So i used the subject prefix for my mailing list so all mailing list mail goes to its own folder (ideally). Then I changed the mailhandler settings to use IMAP and read mail from the aforementioned folder . This will prevent most spam I hope. Also, I don't lose the automatic account creation feature which I like.

Cheers