MailMessageDomainKeysSign Method |
Namespace: MailBee.Mime
public void DomainKeysSign( bool isWebApp, string[] headersToSign, string privateKeyStr, bool isFilename, string selector, DomainKeysTypes dkTypes )
Exception | Condition |
---|---|
MailBeeInvalidArgumentException | privateKeyStr 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. |
MailBeeException | An error occurred and ThrowExceptions is true. |
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 |
---|
Be sure to enable FipsMode if the current system is FIPS-compliant. |
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(); } }