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. Dim mailman As New Chilkat.MailMan() ' Any string argument automatically begins the 30-day trial. Dim success As Boolean success = mailman.UnlockComponent("30-day trial") If (success <> true) Then TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf Exit Sub End If ' We'll also be needing the Chilkat DKIM object. ' The Chilkat DKIM functionality is included in the "Chilkat MIME" license. Dim dkim As New Chilkat.Dkim() success = dkim.UnlockComponent("30-day trial") If (success <> true) Then TextBox1.Text = TextBox1.Text & dkim.LastErrorText & vbCrLf Exit Sub End If ' 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: Dim saUidls As Chilkat.StringArray saUidls = mailman.GetUidls() If (saUidls Is Nothing ) Then MsgBox(mailman.LastErrorText) Exit Sub End If ' 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. Dim i As Long Dim mimeBytes() As Byte Dim k As Long Dim bVerified As Boolean Dim numDkimSigs As Long Dim numDomainKeySigs As Long For i = 0 To saUidls.Count - 1 mimeBytes = mailman.FetchMime(saUidls.GetString(i)) ' Verify each DKIM signature, if any exist. numDkimSigs = dkim.NumDkimSignatures(mimeBytes) For k = 0 To numDkimSigs - 1 bVerified = dkim.VerifyDkimSignature(k,mimeBytes) If (bVerified = true) Then TextBox1.Text = TextBox1.Text & "DKIM signature " _ & k & " verified" & vbCrLf Else TextBox1.Text = TextBox1.Text & "DKIM signature " _ & k & " invalid" & vbCrLf TextBox1.Text = TextBox1.Text & dkim.LastErrorText & vbCrLf End If Next ' Verify each DomainKey signature if any exist. numDomainKeySigs = dkim.NumDomainKeySignatures(mimeBytes) For k = 0 To numDomainKeySigs - 1 bVerified = dkim.VerifyDomainKeySignature(k,mimeBytes) If (bVerified = true) Then TextBox1.Text = TextBox1.Text & "DomainKey signature " _ & k & " verified" & vbCrLf Else TextBox1.Text = TextBox1.Text & "DomainKey signature " _ & k & " invalid" & vbCrLf TextBox1.Text = TextBox1.Text & dkim.LastErrorText & vbCrLf End If Next Next |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.