DomainKeysVerify Method (MailMessage, Smtp, Header)
Verifies the specified DomainKeys and/or DKIM signature of the mail message.

Namespace: MailBee.Security
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public DomainKeysVerifyResult Verify(
	MailMessage msg,
	Smtp dnsRequestor,
	Header dkHeader


Type: MailBee.MimeMailMessage
The mail message to be verified.
Type: MailBee.SmtpMailSmtp
The instance of Smtp class to be used for making DNS queries.
Type: MailBee.MimeHeader
The source message's DomainKey-Signature or DKIM-Signature to be verified.

Return Value

Type: DomainKeysVerifyResult
The result of the verification.
MailBeeInvalidArgumentExceptionmsg or dnsRequestor or dkHeader is a null reference (Nothing in Visual Basic) or dnsRequestor.DnsServers collection is empty or FipsMode is enabled and DKIM verification is requested.
MailBeeExceptionAn error occurred and ThrowExceptions is true.

This overload is useful if the message has multiple DKIM signatures and you want to verify them all.

Note Note
If the current system is FIPS-compliant and runs .NET 2.0/3.5 and the message contains only DKIM signature created using SHA256 algorithm, the method will return Sha256NotSupported or throw an exception if ThrowExceptions is enabled. This can only occur with older .NET versions (before 4.0) because there was no FIPS-certified SHA256 implementation at that time. On a FIPS system, use MailBee.NET.dll for .NET 4.0+ to avoid these issues. All classic DK signatures and those DKIM signatures which use SHA1 algorithm are fully supported on all Windows platforms, including FIPS-compliant ones. You'll still need to enable FipsMode to use FIPS-compliant versions of security algorithms.
This sample loads an e-mail message from file, prepares Smtp object for making DNS queries and verifies all DKIM signatures in the message.
using System;
using MailBee;
using MailBee.Mime;
using MailBee.Security;
using MailBee.SmtpMail;

class Sample
    static void Main(string[] args)

        // Load the message from file (we could also
        // get if from the mail server or elsewhere).
        MailMessage msg = new MailMessage();

        // Prepare Smtp instance for making DNS queries.
        // We assume Smtp license key is already set in config file.
        Smtp mailer = new Smtp();

        DomainKeys dk = new DomainKeys();

        // Get the collection of DKIM-Signature headers.
        HeaderCollection dkimHeaders = msg.Headers.Items("DKIM-Signature");
        if (dkimHeaders == null)
            Console.WriteLine("Message has no DKIM signatures");
            foreach (Header h in dkimHeaders)
                // Verify each DKIM signature.
                DomainKeysVerifyResult dkResult = dk.Verify(msg, mailer, h);
See Also