I am having a tough time getting the latest 7.x-1.x dev branch working. Drupal seems to have a mind of it's own as to whether it wants to accept e-mails or not.

Authentication error for e-mail sent to the OG Mailinglist Mailgun webhook. Check that you've set your API key from Mailgun in /admin/config/group/mailinglist/mailgun

It seems as though the $signature variable on line 85 of og_mailinglist_mailgun.module is sometimes just an empty string. I'm not sure why, I double checked the request coming from Mailgun and it always has a signature parameter in the request. This happens at sporadically it seems, I'd love to know why.

PHP Fatal error: Class name must be a valid object or a string in drupal/includes/common.inc on line 7679

I'm not sure what's up with this, sometimes a message processes properly (albeit not actually posting to the group or creating a node of any type), or it throws this fatal error.

If anyone has any idea or input as to why these problems may be popping up I'd really appreciate it.

Thanks!

CommentFileSizeAuthor
#7 og_mailinglist_from_mailgun.php_.txt1.48 KBmahfiaz

Comments

mahfiaz’s picture

Thanks for testing, it is highly appreciated.

Does admin/config/group/mailinglist/mailgun actually contain your API key? You do not mention if it does.

To test if $signature is set, you could write this into the og_mailinglist_mailgun_new_email() function and look for the message:
drupal_set_message('

All the contents of $_POST: ' . print_r($_POST, TRUE) . '

');

Unfortunately I have no clue why this fatal error pops up. The source reveals it has something to do with entity types which don't have corresponding class.

Is this a new and clean Drupal installation?

tommyvyo’s picture

This is a relatively new (maybe a month old) Drupal installation.

Followed the backtrace from where the fatal error was being thrown and it seems to be coming from this block of code in og_mailinglist_transport.inc:

    // Check if this user is a member of this group (for security).
    if (!og_is_member('node', $email['groupid'], 'user', $email['userid'])) {
      // TODO also check if person is subscribed to this thread -- if they are,
      // let them comment by email.
      throw new Exception(t("You (email: !mailfrom, account page: !account_page) are not a member of this group.  Please join the group via the web site before posting.",
        array(
          '!mailfrom' => $mailfrom,
          '!account_page' => url("user/" . $email['userid'], array('absolute' => TRUE))
        )
      ));
    }

Backtrace looks something like this:

og_mailinglist_mailgun_new_email();
_og_mailinglist_process_email()   : 100   : /srv/www/public_html/sites/all/modules/og_mailinglist/modules/og_mailinglist_mailgun/og_mailinglist_mailgun.module
og_is_member()                    : 166   : /srv/www/public_html/sites/all/modules/og_mailinglist/og_mailinglist_transport.inc
    ARGS: array('node', 1130, 'user', 2);
og_load_entity()                  : 2116  : /srv/www/public_html/sites/all/modules/og/og.module
    ARGS: array(1130, 'user');
entity_load()                     : 2999  : /srv/www/public_html/sites/all/modules/og/og.module 
    ARGS: array(1130, array(NULL));
entity_get_controller()           : 7647  : /srv/www/public_html/includes/common.inc
    ARGS: array(1130);
mahfiaz’s picture

Status: Active » Postponed (maintainer needs more info)

This code in #2 simply checks if the user with sender's mail belongs to the group s/he is trying to post to.

But this aside, could you please pull fresh code and test this again. It might be fixed now.

mahfiaz’s picture

Any news here?

I saw this error a few times myself when I was messing up with the code, but this was quite some time ago.

tommyvyo’s picture

We uninstalled og_mailinglist on our production server and are currently trying to get it re-installed and back to the previous state.

Until we do so we have nothing to report :(

Though I have seen the Class name must be a valid object or a string error on a local drupal install. My boss (tclnj) seems to think it may be due to the fact that og_forum is based on og 7.1.

mahfiaz’s picture

Are you sure you have og_forum installed on Drupal 7? The latest release of og_forum is 6.x-2.x and it has security vulnerability: http://drupal.org/node/1048906

mahfiaz’s picture

StatusFileSize
new1.48 KB

To test recieving emails from Mailgun, you could use the script below (derivate of og_mailinglist_postfix_transport.php). Just set correct values and run it from command line with something like:
php5 og_mailinglist_from_mailgun.php my-group@example.org < /home/me/my-test-email-file

mahfiaz’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

There were actually two problems.
1) poster did not belong to the group he tried to post to, no problem with that not working
2) PHP Fatal error in common.inc - this as said, is an error I have seen myself, but since it hasn't happened since the late September, I think it must be fixed. If not, I would be happy to fix it if it might pop up again with recent code.

tonebari’s picture

Issue summary: View changes

Having encountered this several times and being a prolific coder, I have come up with a method to avoid this. Just a heads up in case I might save someone some grief.
When writing a new module, before installing, just comment out your code. If there is any error in your code, you will get this. After installing debug by uncommenting your code and taking care of screen errors first and then log errors.
It can get quite confusing, particularly if you have dependent modules, and change code in the parent module and introduce an error that is ignored elsewhere, (you may find it in log, but it doesn't affect site functionality).
Then when clearing all caches (like what happens when installing another module) the error suddenly appears. It can be a bear to find.
Keep these ideas in mind, to avoid this trouble. If you hit this wall: You will have to disable all your custom modules and then after manually clearing all cache tables through phpMyAdmin, install your parent module first, and then dependent modules one at a time until you find the error, at which point you will have to go back and forth, disabling the module, clearing caches and inspecting log messages. Again, comment out the code in the offending module to install, then debug. Lastly, uninstall it and then reinstall when you are fairly confident there are no errors.

mahfiaz’s picture

Hey, tonebari, thanks for the heads up. I think you should write a nice tutorial about your experience, it's valuable and would help many. It may only partly apply here, since this code is only hit when an email is received.