I came to the situation described by others here, in our case jenkins users being handled using Active Directory (AD) and commit information coming from GIT (Bitbucket). For a user with my username (Jose Camacho), commit information from GIT included in "Author" part would have the username defined as jose.camacho but users in AD are created using acronyms like jocam (for jose camacho).
My Email address is matched with both users (jose.camacho and jocam), and when trying to send out emails to me, it detects that the user name is jose.camacho (and not jocam!) and when using the realm validation mechanism (AD), AD says "not existing user" and the message "Not sending mail to unregistered user" appears.
For the options that Andréas Berg suggested, I also second Option #1: If there is any kind of user with that email address, why should it be declared as "unregister user"?
– Workaround
Anyway, we are sending Emails from Jenkinsfile using emailext and we did not want to change that way of using Jenkins so we are using right now a "workaround".
We know that the Emails information coming from GIT is correct (close, controled environment) so we disable the "not sending mail to unregistered user" by using a variable included in the EmailExt plugin version 2.58, introducing following code:
def currenVal = RecipientProviderUtilities.SEND_TO_UNKNOWN_USERS
RecipientProviderUtilities.SEND_TO_UNKNOWN_USERS = true
// Send Email with emailext
RecipientProviderUtilities.SEND_TO_UNKNOWN_USERS = currenVal
(this needs to include import hudson.plugins.emailext.plugins.recipients.* and also needs a securiy confirmation)
I know, it is not the better solution, but it works. Hope this helps anyone looking for a workaround.
Code changed in jenkins
User: Andrew Bayer
Path:
src/main/java/hudson/plugins/git/GitChangeSet.java
http://jenkins-ci.org/commit/git-plugin/3607d2ec90f69edcf8cedfcb358ce19a980b8f1a
Log:
[FIXED JENKINS-9016] If no Jenkins user is found for the commit's user.name value, use the username section of the email address instead.