DataFlex
DataFlex
Count the DKIM Signatures in a Message
See more DKIM / DomainKey Examples
Demonstrates the Chilkat Dkim.NumDkimSigs method, which returns the number of DKIM-Signature header fields in a MIME message. The only argument is a BinData holding the complete MIME.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: A message can legitimately carry several DKIM signatures — the original sender's plus ones added by forwarders or mailing lists — so a verifier needs to know how many there are before checking each. This count is what supplies the valid index range for
DkimVerify. Note that it counts header fields by name only, without validating them, so a malformed DKIM-Signature field is still included in the total.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoDkim
Variant vMimeData
Handle hoMimeData
Integer iNumSigs
String sTemp1
Move False To iSuccess
// Demonstrates the Dkim.NumDkimSigs method, which returns the number of DKIM-Signature header
// fields in a MIME message. The only argument is a BinData holding the complete MIME.
Get Create (RefClass(cComChilkatDkim)) To hoDkim
If (Not(IsComObjectCreated(hoDkim))) Begin
Send CreateComObject of hoDkim
End
// Load the complete MIME message.
Get Create (RefClass(cComChilkatBinData)) To hoMimeData
If (Not(IsComObjectCreated(hoMimeData))) Begin
Send CreateComObject of hoMimeData
End
Get ComLoadFile Of hoMimeData "qa_data/received.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMimeData To sTemp1
Showln sTemp1
Procedure_Return
End
// Count the DKIM-Signature header fields. The count includes malformed signatures, since the
// fields are counted without validating their syntax.
Get pvComObject of hoMimeData to vMimeData
Get ComNumDkimSigs Of hoDkim vMimeData To iNumSigs
Showln "The message has " iNumSigs " DKIM-Signature header(s)."
End_Procedure