from #585658: mail2og not working for any user but user 1/site admin, domain missing from mail2og block

I've turned on the mail2og block, and weirdly it displays this text, minus the domain: "You can post to this group by sending an email to test_group_for_tobias@" - this may not be related to this problem.

Comments

robharward’s picture

I have the same problem.

tobias’s picture

Great - glad to have this confirmed.

arthurf, do you have some time to devote to finishing this module? Looks like we have a few testers here now.

Cheers,

Tobias

deggertsen’s picture

I have the same problem and would love to help test.

deggertsen’s picture

I found what I think is the problem though I am no PHP expert.

In the function on line 674 I noticed something.

function mail2og_cck_widget_validate($element, &$form_state) {
  // get the field name so we can check the form_state values for it and validate
  if (! $email = $form_state['values'][$element['#field_name']][$element['#delta']]['value']) {
    // No email address, build the email address from the node title
    $to = mail2og_email_to_address_create($form_state['values']['title']);
    // get the default domain
    $domain = variable_get('mail2og_default_email_domain', null);
    // create the email address
    $form_state['values'][$element['#field_name']][$element['#delta']]['value'] = "$to@$domain";
    drupal_set_message(t('Automatically generated a email address: !address for this group.', array('!address' => "$to@$domain")));
  }
  // There is incoming data, we need to see if we can validate it  
  else {
  	// Was the entered text a valid email address?
    if (! valid_email_address($email)) {
    	// Now we try to create a valid email address with the domain 
    	$email = $email.'@'. variable_get('mail2og_default_email_domain', null);
    	if (! valid_email_address($email)) {
    		form_error($element, t('The email address you entered is not valid, please try again.'));
    	}
    	// Now we just need to update the field with the new value
    	$form_state['values'][$element['#field_name']][0]['value'] = $email;
    }      
  }    
}

The variable $email is only being redefined in the else statement. So if the if statement comes out true then $email is not being redefined how it should in the later function that displays the email address in the block. So what I did was simply copy line 690 and pasted it at the beginning of the function that outputs the block info on line 735 like so:

function theme_mail2og_block_display_email_info($group, $email) {
  $email = $email. variable_get('mail2og_default_email_domain', null);
  $html = array();
  $html[] = t('You can post to this group by sending an email to %email', array('%email' => $email));
  return implode('<br/>', $html);
}

So I'm basically redefining $email again in this theme function. Does this mess anything up? It fixed the address display in the block for me. Anybody else?

socialnicheguru’s picture

this addition works. Thank you!!!!

Edit:
domain does not show up because this expression is not correct

//parse the domain
$domain = preg_replace("/(.*\@)/", '', $to_address);

it's around line 336.

ilo’s picture

Yes, actually, that should be something close to:

$domain = preg_replace("/(.*\@)/", '', $mailbox['mail']);

This way will extract the domain from the selected mailbox address.

jludwig’s picture

Status: Active » Closed (fixed)

Patch committed. Thanks deggertsen and ilo!