After building a test view, I find that the when configuring the views_mail, when I select the email field to send to, I have issues. I am able to select a field that contains a CCK email value, but not the User:Email value. I can see in my view that it has the same value, but it claims that the User:Email value 'does not contain a valid email address'.

Any thoughts?

Comments

somebodysysop’s picture

Here is the code which validates email addresses:

/**
 * Validate the configuration.
 */
function views_mail_view_configure_validate($form, &$form_state) {
  $view = $GLOBALS['current_view'];

  if ($form_state['values']['count'] == 0) {
    form_set_error('count', t('The view you have selected does not contain any recipients.'));
  }
  if (!valid_email_address($form_state['values']['from_mail'])) {
    form_set_error('from_mail', t('The sender e-mail address you have entered is not valid.'));
  }

  $name_field = $form_state['values']['name_field'];
  $email_field = $form_state['values']['email_field'];
  $nid_field = $form_state['values']['nid_field'];
  $additional_mails = $form_state['values']['additional_mails'];
  $count = views_mail_get_recipients($name_field, $email_field, $nid_field, $additional_mails, $view, TRUE);
  if ($count == 0) {
    form_set_error('email_field', t('Either the recipient or one of the additional e-mail fields you have selected does not contain a valid e-mail address.'));
  }

}

And, here is the bit of code that determines whether to add an address to the recipient list:

    if (valid_email_address($email)) {
	  // See if this user has opted out of receiving emails from us.
	  if (views_mail_accept_mail($email) === TRUE) {
        $recipients[$email]['name'] = $name;
        $recipients[$email]['nid'] = $nid;
	  }
	}

So, if the user has opted of of receiving emails, either by unsubscribing to a previous email or by NOT checking the "Accept mail" checkbox in his account settings, then he will not be added to the recipient list. If no users are added to the recipient list, then you get this error message:

Either the recipient or one of the additional e-mail fields you have selected does not contain a valid e-mail address.

Not sure if you supplied an exact error message.

schnizaare’s picture

Status: Active » Closed (fixed)

Thank you for your input. The issue was not having "allow emails" selected on some users. To resolve (admin/settings/views_mail) I checked "Force Group Email Opt In". Problem solved!

Thanks so much!