Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Search/Download only Encrypted EmailsSearching an IMAP mailbox for emails that are encrypted and download. Emails are automatically decrypted.
use chilkat(); $imap = new chilkat::CkImap(); # Anything unlocks the component and begins a fully-functional 30-day trial. $success = $imap->UnlockComponent("Anything for 30-day trial"); if ($success != 1) { print $imap->lastErrorText() . "\n"; exit; } # Connect to an IMAP server. $success = $imap->Connect("www.cknotes.com"); if ($success != 1) { print $imap->lastErrorText() . "\n"; exit; } # Login $success = $imap->Login("myLogin","myPassword"); if ($success != 1) { print $imap->lastErrorText() . "\n"; exit; } # Select an IMAP mailbox $success = $imap->SelectMailbox("Inbox"); if ($success != 1) { print $imap->lastErrorText() . "\n"; exit; } # An S/MIME encrypted email should have a content-type # header containing the substring "pkcs7-mime": $headerSearch = "HEADER Content-Type pkcs7-mime"; $fetchUids = 1; # messageSet is a CkMessageSet $messageSet = $imap->Search($headerSearch,$fetchUids); if ($messageSet eq null ) { print $imap->lastErrorText() . "\n"; exit; } # Download the emails indicated in the messageSet. # The emails are automatically decrypted. # bundle is a CkEmailBundle $bundle = $imap->FetchBundle($messageSet); if ($bundle eq null ) { print $imap->lastErrorText() . "\n"; exit; } # Display some information from each email: for ($i = 0; $i <= $bundle->get_MessageCount() - 1; $i++) { # email is a CkEmail $email = $bundle->GetEmail($i); print $email->getHeaderField("Date") . "\r\n"; print $email->subject() . "\r\n"; print $email->ck_from() . "\r\n"; print "Received Encrypted: " . $email->get_ReceivedEncrypted() . "\r\n"; if ($email->get_ReceivedEncrypted() == 1) { print "Successfully Decrypted: " . $email->get_Decrypted() . "\r\n"; } print "Received Signed: " . $email->get_ReceivedSigned() . "\r\n"; if ($email->get_ReceivedSigned() == 1) { print "Signature Verified: " . $email->get_SignaturesValid() . "\r\n"; } print "--" . "\r\n"; } # Disconnect from the IMAP server. $imap->Disconnect(); |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.