FindOrCreateContactByEmail action only searches primary email addresses
Overview
FindOrCreateContactByEmail
action use
$result = civicrm_api3('Contact', 'getvalue', [
'return' => "id",
'email' => $email,
]);
to locate existing contacts. This call only searches primary emails, if a contact has an alternative email address specified, won't be found and a new, duplicate contact will be created.
Proposal
Changing this to
$result = civicrm_api3('Email', 'get', [
'return' => ["contact_id"],
'email' => $email,
]);
would find the contact.
Note
I'm happy to provide a PR.