diff -Nur dk-milter-0.4.1.orig/dk-filter/dk-filter.c dk-milter-0.4.1/dk-filter/dk-filter.c
--- dk-milter-0.4.1.orig/dk-filter/dk-filter.c	2006-05-20 05:42:05.000000000 +0800
+++ dk-milter-0.4.1/dk-filter/dk-filter.c	2006-08-22 08:45:33.615662379 +0800
@@ -2076,6 +2076,13 @@
 	dfc = cc->cctx_msg;
 	assert(dfc != NULL);
 
+        /* Determine the job ID for logging. */
+        if (dfc->mctx_jobid == 0 || strcmp(dfc->mctx_jobid, JOBIDUNKNOWN) == 0) {
+                char *jobid = smfi_getsymval(ctx, "i");
+                if (jobid != 0)
+                        dfc->mctx_jobid = jobid;
+        }
+
 	/* get hostname; used in the X header and in new MIME boundaries */
 	hostname = smfi_getsymval(ctx, "j");
 	if (hostname == NULL)
