diff --git a/greenmail-core/src/main/java/com/icegreen/greenmail/util/GreenMail.java b/greenmail-core/src/main/java/com/icegreen/greenmail/util/GreenMail.java
index <HASH>..<HASH> 100644
--- a/greenmail-core/src/main/java/com/icegreen/greenmail/util/GreenMail.java
+++ b/greenmail-core/src/main/java/com/icegreen/greenmail/util/GreenMail.java
@@ -239,7 +239,7 @@ public class GreenMail extends ConfiguredGreenMail {
 

     @Override

     public GreenMailUser setUser(String email, String login, String password) {

-        GreenMailUser user = managers.getUserManager().getUser(email);

+        GreenMailUser user = managers.getUserManager().getUser(login);

         if (null == user) {

             try {

                 user = managers.getUserManager().createUser(email, login, password);
Fixed bug where GreenMail creates user by email address and not by login