MailMessageDomainKeysSign Method
Signs the current e-mail message with DKIM and classic DomainKeys signatures.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public void DomainKeysSign(
	bool isWebApp,
	string[] headersToSign,
	string privateKeyStr,
	bool isFilename,
	string selector,
	DomainKeysTypes dkTypes
)

Parameters

isWebApp
Type: SystemBoolean
Must be true for ASP.NET applications, false otherwise.
headersToSign
Type: SystemString
The array of the names of the headers to be included in the signature, or a null reference (Nothing in Visual Basic) if all the message headers should be included in the signature.
privateKeyStr
Type: SystemString
The contents or the filename of the DomainKeys/DKIM private key.
isFilename
Type: SystemBoolean
If true, privateKeyStr denotes the private key filename; otherwise, the contents.
selector
Type: SystemString
The prefix of the sub-domain serving DomainKeys/DKIM for the sender domain.
dkTypes
Type: MailBee.SecurityDomainKeysTypes
Specifies which signatures to create (classic DK, newer DKIM, or both).
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionprivateKeyStr or selector is a null reference (Nothing in Visual Basic) or the message to be signed does not include the header specifying the sender (Sender or From header) or headersToSign array (if not null) does not list the name of that header or the sender's e-mail address domain is empty.
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks

If you need more advanced level of DomainKeys/DKIM signing or additional information on private keys, certificates and so on, refer to DomainKeys class.

Moreover, in ideal case it should be your your mail server's job to sign outgoing e-mails with DomainKeys/DKIM signatures. Use MailBee only if you cannot enable this feature on your mail server.

To make MailBee automatically DK/DKIM sign all outgoing e-mail messages created from this MailMessage instance, call SetDomainKeysSignOnSend(Boolean, Boolean, String, String, Boolean, String, DomainKeysTypes) method of Builder object.

Note Note
Be sure to enable FipsMode if the current system is FIPS-compliant.
Examples
This sample composes a simple e-mail, signs it with DomainKeys and DKIM signatures and sends it out. We assume the private certificate is in "C:\Temp\rsa512.private" file and the domain selector is "dk".
using System;
using MailBee;
using MailBee.Mime;
using MailBee.SmtpMail;
using MailBee.Security;

class Sample
{
    static void Main(string[] args)
    {
        // Initialize mailer.
        Smtp mailer = new Smtp();

        // Set the message properties.
        mailer.Message.From.Email = "john.doe@company.com";
        mailer.Message.To.Add("jane.doe@example.com");
        mailer.Message.Subject = "Hello";
        mailer.Message.BodyPlainText = "Hello, Jane, can we meet today?";

        // Sign the message with DomainKeys and DKIM.
        mailer.Message.DomainKeysSign(false, null, @"C:\Temp\rsa512.private", true, "dk", DomainKeysTypes.Both);

        // Send the message via SMTP server (authentication is used in this sample).
        mailer.SmtpServers.Add("mail.company.com", "john.doe@company.com", "secret");
        mailer.Send();
    }
}
See Also