I realized when a new check-in is performed in TFS. It tries to look into the people's list of jenkins to map the user based on UserName. If the mapping exists everything works fine but if it doesn't exists a new dummy user is created with that username with incorrect details.
And the mail is then sent incorrectly.
eg. If user with username A12345 performs a check-in. And this user is not present in the people directory. Then a new id is created with username A12345. And in case of failure, it tries to send mail to A12345@domail.com.
This is not correct as the username is not mapped to correct Email address. Perhaps it could be done a little better.
We are now using a workaround to once perform the login of all the users present in Active Directory in jenkins using there credentials. This way a correct user with correct email mapping is created in jenkins(people) and everything works fine.
- Try looking up a user's email and comparing that.
- Looking up the user's email in Active Directory, if Active Directory is being used.
The last would be ideal for us.