I'm using the nodejs module "dkim signer" to authenticate emails I send from my server application. I implement it exactly as the documentation shows, but dkimvalidator.com and Mail-tester.com both show that the body is altered when it arrives every time I send an email. The following is the exact code I'm test-sending. Can anybody please tell me what I'm doing wrong that's causing the corruption?
var message =
MIME-Version: 1.0\r\n
+
DATE: <${DATE_AND_TIME}>\r\n
+
Message-ID: <${uuidv4()}@example.com>\r\n
+
SUBJECT: ${subject}\r\n
+
FROM: John Doe <john_doe@example.com>\r\n
+
TO: <${email}>\r\n
+
REPLY-TO: John Doe <biz-dev@example.com>\r\n
+
Content-Type: multipart/alternative; boundary=boundary42\r\n\r\n\r\n
+
--boundary42\r\n
+
Content-Type: text/plain; charset=utf-8\r\n\r\n
+
${text}\r\n\r\n
+
--boundary42\r\n
+
Content-Type: text/html; charset=utf-8\r\n\r\n
+
${html}\r\n\r\n
+
--boundary42--\r\n
+
.\r\n
+
QUIT\r\n
var dkimOptions = { domainName: "example.com", keySelector: "priv_server", privateKey: require("fs").readFileSync("./privKey.pem") };
var signedMessage = DKIMSign(message, dkimOptions);
I did everything in the code above, and expected a perfect delivery, but never get it.