diff -u -r dovecot-2.2.15.orig/src/auth/auth-request.c dovecot-2.2.15/src/auth/auth-request.c
--- dovecot-2.2.15.orig/src/auth/auth-request.c	2014-10-24 19:38:13.000000000 -0400
+++ dovecot-2.2.15/src/auth/auth-request.c	2014-10-30 08:37:33.059630271 -0400
@@ -24,7 +24,9 @@
 #include "userdb-blocking.h"
 #include "userdb-template.h"
 #include "password-scheme.h"
-
+#if defined(PASSDB_VPOPMAIL) && defined(POP_AUTH_OPEN_RELAY)
+#include "userdb-vpopmail.h"
+#endif
 #include <stdlib.h>
 #include <sys/stat.h>
 
@@ -140,6 +142,26 @@
 	auth_request_refresh_last_access(request);
 	auth_request_handler_reply(request, AUTH_CLIENT_RESULT_SUCCESS,
 				   data, data_size);
+
+#if defined(PASSDB_VPOPMAIL) && defined(POP_AUTH_OPEN_RELAY)
+	if (strcasecmp(request->service, "POP3") == 0 ||
+	    strcasecmp(request->service, "IMAP") == 0) {
+		const char *host = net_ip2addr(&request->remote_ip);
+		/* vpopmail 5.4 does not understand IPv6 */
+		if (host[0] != '\0' && IPADDR_IS_V4(&request->remote_ip)) {
+			/* use putenv() directly rather than env_put() which
+			   would leak memory every time we got here. use a
+			   static buffer for putenv() as SUSv2 requirements
+			   would otherwise corrupt our environment later. */
+			static char ip_env[256];
+
+			i_snprintf(ip_env, sizeof(ip_env),
+				   "TCPREMOTEIP=%s", host);
+			putenv(ip_env);
+			open_smtp_relay();
+		}
+	}
+#endif
 }
 
 void auth_request_fail(struct auth_request *request)
diff -u -r dovecot-2.2.15.orig/src/auth/passdb-vpopmail.c dovecot-2.2.15/src/auth/passdb-vpopmail.c
--- dovecot-2.2.15.orig/src/auth/passdb-vpopmail.c	2014-06-02 07:50:10.000000000 -0400
+++ dovecot-2.2.15/src/auth/passdb-vpopmail.c	2014-10-30 03:36:36.365835144 -0400
@@ -148,26 +148,6 @@
 		return;
 	}
 
-#ifdef POP_AUTH_OPEN_RELAY
-	if (strcasecmp(request->service, "POP3") == 0 ||
-	    strcasecmp(request->service, "IMAP") == 0) {
-		const char *host = net_ip2addr(&request->remote_ip);
-		/* vpopmail 5.4 does not understand IPv6 */
-		if (host[0] != '\0' && IPADDR_IS_V4(&request->remote_ip)) {
-			/* use putenv() directly rather than env_put() which
-			   would leak memory every time we got here. use a
-			   static buffer for putenv() as SUSv2 requirements
-			   would otherwise corrupt our environment later. */
-			static char ip_env[256];
-
-			i_snprintf(ip_env, sizeof(ip_env),
-				   "TCPREMOTEIP=%s", host);
-			putenv(ip_env);
-			open_smtp_relay();
-		}
-	}
-#endif
-
 	callback(PASSDB_RESULT_OK, request);
 }
 
