Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
POP3 Verify DKIM SignaturesDownload the email from a POP3 mailbox and verify each DKIM or DomainKey signature.
// The mailman object is used for receiving (POP3) // and sending (SMTP) email. Chilkat.MailMan mailman = new Chilkat.MailMan(); // Any string argument automatically begins the 30-day trial. bool success; success = mailman.UnlockComponent("30-day trial"); if (success != true) { textBox1.Text += mailman.LastErrorText + "\r\n"; return; } // We'll also be needing the Chilkat DKIM object. // The Chilkat DKIM functionality is included in the "Chilkat MIME" license. Chilkat.Dkim dkim = new Chilkat.Dkim(); success = dkim.UnlockComponent("30-day trial"); if (success != true) { textBox1.Text += dkim.LastErrorText + "\r\n"; return; } // Set the POP3 server's hostname mailman.MailHost = "mail.cknotes.com"; // Set the POP3 login/password. mailman.PopUsername = "admin@cknotes.com"; mailman.PopPassword = "myPassword"; // First, get the complete set of UIDLs for the email in the POP3 mailbox: Chilkat.StringArray saUidls = null; saUidls = mailman.GetUidls(); if (saUidls == null ) { MessageBox.Show(mailman.LastErrorText); return; } // Download each email into a byte array // If DKIM signature verification is to be performed, // it is important to download the email exactly as-is. int i; byte[] mimeBytes = null; int k; bool bVerified; int numDkimSigs; int numDomainKeySigs; for (i = 0; i <= saUidls.Count - 1; i++) { mimeBytes = mailman.FetchMime(saUidls.GetString(i)); // Verify each DKIM signature, if any exist. numDkimSigs = dkim.NumDkimSignatures(mimeBytes); for (k = 0; k <= numDkimSigs - 1; k++) { bVerified = dkim.VerifyDkimSignature(k,mimeBytes); if (bVerified == true) { textBox1.Text += "DKIM signature " + Convert.ToString(k) + " verified" + "\r\n"; } else { textBox1.Text += "DKIM signature " + Convert.ToString(k) + " invalid" + "\r\n"; textBox1.Text += dkim.LastErrorText + "\r\n"; } } // Verify each DomainKey signature if any exist. numDomainKeySigs = dkim.NumDomainKeySignatures(mimeBytes); for (k = 0; k <= numDomainKeySigs - 1; k++) { bVerified = dkim.VerifyDomainKeySignature(k,mimeBytes); if (bVerified == true) { textBox1.Text += "DomainKey signature " + Convert.ToString(k) + " verified" + "\r\n"; } else { textBox1.Text += "DomainKey signature " + Convert.ToString(k) + " invalid" + "\r\n"; textBox1.Text += dkim.LastErrorText + "\r\n"; } } } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.