AutoIt
AutoIt
POP3 Verify Signed (S/MIME) Email
Demonstrates how to download and verify digitally signed S/MIME email.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oMailman = ObjCreate("Chilkat.MailMan")
; Set the POP3 server's hostname
$oMailman.MailHost = "pop.example.com"
; Set the POP3 login/password.
$oMailman.PopUsername = "myLogin"
$oMailman.PopPassword = "myPassword"
$oStUidls = ObjCreate("Chilkat.StringTable")
$bSuccess = $oMailman.FetchUidls($oStUidls)
If ($bSuccess = False) Then
ConsoleWrite($oMailman.LastErrorText & @CRLF)
Exit
EndIf
$oEmail = ObjCreate("Chilkat.Email")
$oCert = ObjCreate("Chilkat.Cert")
Local $iCount = $oStUidls.Count
Local $i = 0
While $i < $iCount
; Download the full email.
$bSuccess = $oMailman.FetchByUidl($oStUidls.StringAt($i),False,0,$oEmail)
If ($bSuccess = False) Then
ConsoleWrite($oMailman.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($i & @CRLF)
ConsoleWrite("From: " & $oEmail.From & @CRLF)
ConsoleWrite("Subject: " & $oEmail.Subject & @CRLF)
; The security layers of signed and/or encrypted emails
; are automatically "unwrapped" when loaded into
; a Chilkat email object.
; An application only needs to check to see if an email
; was received signed or encrypted, and then examine
; the success/failure. For example:
If ($oEmail.ReceivedSigned = True) Then
ConsoleWrite("This email was signed." & @CRLF)
; Check to see if the signatures were verified.
If ($oEmail.SignaturesValid = True) Then
ConsoleWrite("Digital signature(s) verified." & @CRLF)
ConsoleWrite("Signer: " & $oEmail.SignedBy & @CRLF)
$bSuccess = $oEmail.LastSignerCert(0,$oCert)
If ($bSuccess = False) Then
ConsoleWrite($oEmail.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Signing cert: " & $oCert.SubjectCN & @CRLF)
EndIf
Else
ConsoleWrite("Digital signature verification failed." & @CRLF)
EndIf
$i = $i + 1
Wend
$oMailman.Pop3EndSession()