-dkim->dot_stuffed = !!(save_options & topt_end_dot);
-if (!(dkim_signature = dkim_exim_sign(deliver_datafile, SPOOL_DATA_START_OFFSET,
- hdrs, dkim, &errstr)))
+/* The dotstuffed status of the datafile depends on whether it was stored
+in wireformat. */
+
+dkim->dot_stuffed = f.spool_file_wireformat;
+if (!(dkim_signature = dkim_exim_sign(deliver_datafile,
+ spool_data_start_offset(message_id), hdrs, dkim, &errstr)))