diff --git a/Makefile.am b/Makefile.am
index 53a4d10288e8f11984c0ab597add429d0473f930..9f2d3d2096bcaa9d7c714f0a37bcfd9e0f6c5f48 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -193,10 +193,10 @@ test_cases = \
 
 prepare_test_cases:
 	$(AM_V_at)for case in $(test_utf8_cases); do \
-		if test @HAVE_MAIL_UTF8@ = 1; then \
-		  $(SED) -s -e 's/#UTF8#.*//' $${case}.in > $$case ; \
-		else \
+		if test $(DOVECOT_HAVE_MAIL_UTF8) = yes; then \
 		  $(SED) -s -e 's/#UTF8#//' $${case}.in > $$case ; \
+		else \
+		  $(SED) -s -e 's/#UTF8#.*//' $${case}.in > $$case ; \
 		fi; \
 	done
 
diff --git a/configure.ac b/configure.ac
index d406e635cbeb37785b9e73e3f34bf4c6f2412888..ba24a322ee341c3763d8c0ec08ef405c78dbe3ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,8 +49,6 @@ AC_SUBST(BINARY_CFLAGS)
 AC_SUBST(BINARY_LDFLAGS)
 AC_SUBST(LIBDOVECOT_INCLUDE)
 
-DC_HAVE_MAIL_UTF8
-
 AC_SUBST(PIGEONHOLE_ASSET_VERSION, regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\).\([0-9]+\)], [\1.\2.\3]))
 AS_IF([test $PIGEONHOLE_ASSET_VERSION = "0.0.0"], [
    AC_SUBST([PIGEONHOLE_ASSET_VERSION], "main")