-
Notifications
You must be signed in to change notification settings - Fork 3
opendkim.body()
Christopher Mooney edited this page Feb 12, 2018
·
3 revisions
Handle a piece of a message's body. The body block should contain normal CRLF
line termination and be in canonical form (e.g., with dot-stuffing removed, if any). opendkim.body()
is called zero or more times between opendkim.eoh()
and opendkim.eom()
.
For more information:
http://www.opendkim.org/libopendkim/dkim_body.html
Type: Object
-
body
: The body chunk with normalCRLF
line termination, no dot-stuffing, and the terminating DOT removed. -
length
: length of the body chunk.
- On failure, an exception is thrown that indicates the cause of the problem.
- Dot stuffing and the terminating dot in the message body are expected to be removed by the caller. If they appear within body, they are assumed to be part of the message body and will be included in the hashed data. This is true of any content modification that might be done by the MTA.
const OpenDKIM = require('node-opendkim');
async function verify(header, body) {
var opendkim = new OpenDKIM();
try {
await opendkim.verify({id: undefined});
await opendkim.header({
header: header,
length: header.length
});
await opendkim.eoh();
await opendkim.body({
body: body,
length: body.length
});
await opendkim.eom();
} catch (err) {
console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
console.log(err);
}
}
const OpenDKIM = require('node-opendkim');
function verify_sync(header, body) {
var opendkim = new OpenDKIM();
try {
opendkim.verify_sync({id: undefined});
opendkim.header_sync({
header: header,
length: header.length
});
opendkim.eoh_sync();
opendkim.body_sync({
body: body,
length: body.length
});
opendkim.eom_sync();
} catch (err) {
console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
console.log(err);
}
}
const OpenDKIM = require('node-opendkim');
function verify(opendkim, header, body, callback) {
opendkim.verify({id: undefined}, function (err, result) {
if (err) {
return callback(err, result);
}
var header_obj = {
header: header,
length: header.length
};
opendkim.header(header_obj, function (err, result) {
if (err) {
return callback(err, result);
}
opendkim.eoh(function (err, result) {
if (err) {
return callback(err, result);
}
var body_obj = {
body: body,
length: body.length
};
opendkim.body(body_obj, function (err, result) {
if (err) {
return callback(err, result);
}
opendkim.eom(function (err, result) {
if (err) {
return callback(err, result);
}
return callback(err, result);
});
});
});
});
}
var opendkim = new OpenDKIM();
verify(opendkim, header, body, function (err, result) {
if (err) {
return console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
}
// success
});