Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.1.5
-
Fix Version/s: 4.3.0
-
Component/s: Core CiviCRM
-
Labels:None
Description
I've probably figured out an issue where people attempting to send outgoing email are blocked with a "Your user record does not have a valid email address" error, even though they have one or more valid email addresses.
The user in question has a contact with 3 locations, the first and the third of which have valid email addresses. The second location does not have a valid email address (email is NULL for that location), and the error is getting generated in CRM/Contact/Form/Task/EmailCommon.php, at line 107:
if ($form->_noEmails) {
CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
}
The cause of the error seems to be a "fence post" error: the code
foreach ($contactEmails as $emailId => $item) { $email = $item['email']; if (!$email && (count($emails) <= 1) ) { $emails[$emailId] = '"' . $fromDisplayName . '"'; $form->_noEmails = TRUE; }
should really be
foreach ($contactEmails as $emailId => $item) { $email = $item['email']; if (!$email && (count($emails) < 1) ) { $emails[$emailId] = '"' . $fromDisplayName . '"'; $form->_noEmails = TRUE; }