I can't for the life of me figure out how to get mail2web working. Whenever I turn the module on, all mailhandler rules stop working - even the ones that worked fine before to post to the blog by email. I get "Received an email with no parameters from..." messages in the log and no messages are not posted.

- drupal 5.11
- notifications 5.x-1.0
- messaging 5.x-1.0
- mailhandler 5.x-1.4

What other info might you need?

I would be massively grateful to anyone who can help me sort this out. The feature is promising and I want to start using it ASAP.

Thanks!

Tobias

CommentFileSizeAuthor
#8 mail2web.patch667 bytessagannotcarl

Comments

Ian Ward’s picture

Project: Notifications » Mail to Web
Version: 5.x-1.0 » 5.x-1.0-beta1

hi Tobias,

There is a dev version now available to download and test on http://drupal.org/project/mail2web which you could try on a test site. The other mailhandler rules should now continue to work in the dev version. Once this is tested some more, i'll roll another beta version. I'm going to switch this ticket to the mail2web project as I imagine it is a mail2web issue.

There is a post about configuring mail2web over here http://www.developmentseed.org/blog/2008/apr/30/reply-above-line-post-co...

Can you tell me what email client you are using to respond to the message?

thanks,
Ian

JamesCollier’s picture

Version: 5.x-1.0-beta1 » 6.x-1.0-beta1

Hi,
I've installed everything on a Drupal 6 dev site, and know what the problem is, though admittedly I don't have the technical know-how to fix it.
When Mail to Web is not enabled, all works as it should with Mailhandler, Notifications and all other modules, and I can email in a post with no errors. When Mail to Web is enabled, it requires authentication parameters (that assign responses to certain nodes, or to previous comments) that are not present in a new post, and thus the emailed post is not processed.
Thanks for looking into all of this,
James

jide’s picture

I confirm what JamesCollier says, thus i have been able to make it work first.
Then, i added a new mailbox in mailhandler and the error now occurs (i made some other changes i can't remember too, sorry).
I tried to look at the module, but for now, i have no clue.

jide’s picture

The mailhandler hook does not return $node if the mail does not contain information required by mail2web.
A simple fix is to return the node as a fallback. Look for the function mail2web_mailhandler, line 158 :

/**
 * Implementation of hook_mailhandler()
 */
function mail2web_mailhandler($node, $result, $i, $header, $mailbox) {
  // ... (actual code goes here)
  return $node;
}
nsciacca’s picture

The problem with the missing parameters is as such:

1. Mail2Web constructs a Message ID like this: <1.2.13.1229449723.eec24b28f146e19f4153bc704ec58437@example.com>

2. The received mail message has a header Message ID like this: <ea7cb714cfaa049aad94d365de07f7a9@example.com>

So when you reply - the Message ID cannot be broken back apart into the "uid.nid.cid.time.signature" fields. I'm still looking into where/why the Message ID is not being sent correctly.

*UPDATE*

I was using the PHPMailer and when I dug into the "messaging_phpmailer.module" I found that the Message ID was NOT being passed along to the send function, so it was generating a random message ID -- so I added the following:

(messaging_phpmailer.module - line 84)
// Add MessageID header
$mail->MessageID = $message['headers']['Message-ID'];

The Message ID was successfully passed to the email and the Reply function posted a comment reply - the subject of the email was successfully added as the subject of the comment reply - BUT the content of the email/comment is blank... investigating now...

*UPDATE*

The preg_split in "mail2web.module" to deal with the mac mail client was causing a problem -- the partial HTML tags from the HTML email was causing the preg_split not to identify the key part of the message correctly. I added the following line before the preg_split:

(mail2web.module - line 191)
// Let's strip out any html tagging that may be adding by the email client
$node->body = strip_tags($node->body);

Of course this only works if you don't care to have HTML in your comments -- the reason the preg_split wasn't working was that the comment text was prefaced with: <html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">. So lesson learned: either only send back plain text emails, or write an advanced filter to take out the lines before the comment text.

nsciacca’s picture

The problem with the hook_mailhandler is that it runs on every email message, not just the one that has been marked to be used as the Web2Mail address, the following code fixes that by first checking to see if the mailbox matches:

(mail2web.module - line 162 --[just after the function is defined, before any processing])
// let's make sure this was sent to the email address used to process mail2web - otherwise return the node and move on
$mailboxes = mail2web_mailbox_list();
$index = variable_get('mail2web_mailbox', '');
if (!in_array($mailboxes[$index],$mailbox)) {
  // not our configured email mailbox, so return the node
  return $node;
} 	
sagannotcarl’s picture

Version: 6.x-1.0-beta1 » 5.x-1.x-dev
Status: Active » Needs review

#6 fixed the problem for me for version 5-x-dev.. Here is the same code as a patch.

Thanks nsciacca.

It doesn't look like the line numbers mentioned work for the 6-x version so I'm switching the version of the issue. If I'm wrong please excuse me, and maybe give a little more context for that code snippet.

sagannotcarl’s picture

StatusFileSize
new667 bytes

And the patch...

cglusky’s picture

Version: 5.x-1.x-dev » 6.x-1.0-beta1
Status: Needs review » Needs work

We need to get more info on this issue and keep the versions from changing:) There are some differences in level of development with this module. E.g. The latest 5.x version already has the code that makes this check - although it does not read the same as #6. Please review the latest dev version for 5 as this fix is already in place. Matter o' fact I used it to update the 6.x version.

We start out with this:

/**
 * Implementation of hook_mailhandler()
 */
function mail2web_mailhandler($node, $result, $i, $header, $mailbox) {
  //  Get vars so we can make sure we are working with a M2W mailbox
  $mailbox_mid = variable_get('mail2web_mailbox', '');
  $mbox = mailhandler_get_mailbox($mailbox_mid);
  $mbox_name = $mbox['mail'];
  // The In-reply-to header is cleaned and passed in $node->threading
  if ($header->toaddress == $mbox_name && $node->threading && ($params = mail2web_check_messageparams($node->threading, $header)) && empty($params['error'])) {
    // Now check user id , just go ahead if they match and it is a valid user
    if ($node->uid && $node->uid == $params['uid']) {

do more stuff in here, and end with this:

 // If we reach here, there has been an error. Check error code or send a generic one.
  // This part doesn't return a node so it won't be further processed by mailhandler
  if ($header->toaddress == $mbox_name && $params) {
    mail2web_error($params['error'], $node, $header);
  } 
  elseif ($header->toaddress == $mbox_name && !$params) {
    mail2web_error(MAIL2WEB_ERROR_PARAMS, $node, $header);
  }
  // If the message is not addressed to the mail2web mailbox, give the node back to mailhander for delegation.
  elseif ($header->toaddress != $mbox_name) {
    return $node;
  }

I am testing this and it seems to work but I question rather we should be returning $node. Think it might be null as mailhandler may think we have done something in our function when we have not.

The patch in #6 does essentially the same thing, I am just going for consistency between modules.

R,
C

cglusky’s picture

OK, I have had a chance to test my code a bit using Apple Mail and .Mac Web client with good luck. I will have a patch shortly but it may address a few more items, so I will cross post in here if it ends up being inline with Ian and Jose's plans.

Right now I am just focused on getting this all working with plain text and considering HTML input/output as gravy.

R,
Coby

[EDIT] This is part of a bigger patch I proposed here http://drupal.org/node/351260

Ian Ward’s picture

Status: Needs work » Closed (duplicate)

The issues discussed on this thread are duplicates of:

http://drupal.org/node/257588 (issue where mail2web blocks other uses of mailhandler)
http://drupal.org/node/290214 (issue where messageid is getting mangled or removed by some email clients)

By the end of this week the second beta will be released for both versions, and both of these issues will be fixed. I am marking this issue as a duplicate of the above mentioned two issues.

sagannotcarl’s picture

Version: 6.x-1.0-beta1 » 6.x-1.0-beta2
Category: support » bug
Status: Closed (duplicate) » Active

I am reopening this because the issues that this was marked a duplicate of (#257588: mail2web blocks other modules from using mailhandler, #290214: Extend mail2web support for mail clients (Yahoo mail) and some html cleaning up, and potentially portions of #351260: Proposed Changes For D6 Version) have been committed and I'm still getting this error. If I should be opening a new instead issue please let me know.

My comment is properly getting processed and posted using SquirrelMail and Roundcube webmail, but when I use Apple Mail, Outlook express, or gmail I get the parameters error.

Are people having luck with these email clients? If so what versions of mail to web / notifications / messaging are you using?

I'm using:
* Mail to Web 6.x-1.0-beta 2
* Messaging 6.x-1.1
* Notifications 6.x-1.1

Thanks,
Colin

sagannotcarl’s picture

Version: 6.x-1.0-beta2 » 6.x-1.x-dev

I've been digging around trying to figure this out in the dev version. I don't really know what the ramifications are of this but I've found a clue. Maybe someone else can chime in as to what is going on.

I think my issue has to do with this code starting on line 197 of mail2web.module:

  // The In-reply-to header is cleaned and passed in $node->threading
  // Check to see if the header info is present as it may have been stripped by some mail clients
  // If it's not present check the email for backup signature
  if (!$node->threading) { 
     $node->threading = _mail2web_get_backup_messageid($node->body);
  }

If I comment out the if (!$node->threading) so that $node->threading = _mail2web_get_backup_messageid($node->body); runs no matter what then email is properly processed from every email client. Oddly enough it doesn't clean the "On April 17th..." stuff anymore though.

I started looking here because I realized that whenever I was getting an error _mail2web_get_backup_messageid wasn't being called.

This may just be an indication that something else isn't working elsewhere but it's as far as I got.

sagannotcarl’s picture

Status: Active » Fixed

I think I've figured out what my problem is and it looks like it's just an issue with using PHPMailer and headers.

When using PHPMailer there is an extra message id header and it's confusing things. There is an issue and a patch here: #363001: messaging_phpmailer does not use passed headers - fails with mail2web module.

Moving this back to fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tclusellas’s picture

Just to report that I was not able to post comments via email with subjects that included extra words like: "Re:"
I followed sagannotcarl advice on #13,
it fixed my problem.

Thanks

Ian Ward’s picture

Project: Mail to Web » Mail Comment

Switch to mailcomment project. Mail2web is now known as "mailcomment" due to a trademark issue with the name mail2web.