What you think was an email address, it's not really it. It's referring to the Active Directory property User Principal Name instead. If really that the user is changing their email address - not the User Principal Name - then your code will still work. But there's a catch.
Firstly before giving an answer, you need to understand how User Profile works in SharePoint. Inside SharePoint, you've got 2 'user information databases'. As per normal usage, any changes coming from the Active Directory will be synced to the SharePoint User Profile database. Do a check on your SharePoint Central Administration - User Profile, then find that user's profile. Verify whether the email address and account name are still the same or it was synchronized accordingly.
Note: If the account name is changing, then the same user has been provisioned with a new user account completely.
Secondly, there is another 'user information database' that is stored within a hidden SharePoint List in each Site Collection separately, called 'User Information List'. Any query to the API _api/web/siteUsers will be done against this list directly. The reason why this list exists, mainly to achieve good performance.
You can go by this address (add /_catalogs/users/simple.aspx):
https://yoursharepointsitecolladdress.com/_catalogs/users/simple.aspx
When this list will be updated? When a user first time accessing your site collection, the user's information will be automatically added to this list. It's the same case when there is an update, the user must explicitly visit the site collection to get this list updated. If the user never in their life visited the Site Collection, your query likely fails. This legacy list is still there even nowadays with Office 365 world and still adopting the old mechanism. Read it on: https://zimmergren.net/sharepoints-hidden-user-list-user-information-list/.
Sometimes, this list is not getting updated instantly whenever there is a change and Microsoft acknowledges that. This is why we've got an API '/_api/web/ensureUser'.
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + '/_api/web/ensureUser',
type: 'POST',
contentType: 'application/json;odata=verbose',
data: JSON.stringify({ 'logonName': 'i:0#.f|membership|[email protected]' }),
headers: {
'X-RequestDigest': $('#__REQUESTDIGEST').val(),
"accept": "application/json;odata=verbose"
}
});
Read it on https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245233(v=office.15).
This API will force update the User Information List from SharePoint User Profile.
Another thing worth looking at, you could use another way to query based on other properties.
_spPageContextInfo.webAbsoluteUrl + "/_api/web/siteUsers?$filter=Title eq 'Sunil'"
_spPageContextInfo.webAbsoluteUrl + "/_api/web/siteUsers?$filter=LoginName eq '" + encodeURIComponent('i:0#.f|membership|[email protected]') + "'"
_spPageContextInfo.webAbsoluteUrl + "/_api/web/siteUsers?$filter=Email eq '" + encodeURIComponent('[email protected]') + "'"
Hope it helps. Other references: