Perl Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Perl Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
SMTP
Socket / SSL
Spider
SFTP
SSH Key
SSH
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

 

SSL POP3 with Certificates

Demonstrates how to use a client-side certificate with an SSL connection to a POP3 server. Also demonstrates how to get the POP3 server's SSL certificate.

 Chilkat Perl Module Downloads for Windows, Linux, and MAC OS X

use chilkat();

#  The mailman object is used for receiving (POP3)
#  and sending (SMTP) email.
$mailman = new chilkat::CkMailMan();

#  Any string argument automatically begins the 30-day trial.
$success = $mailman->UnlockComponent("30-day trial");
if ($success != 1) {
    print "Component unlock failed" . "\n";
    exit;
}

#  Set the GMail account POP3 properties.
$mailman->put_MailHost("pop.gmail.com");
$mailman->put_PopUsername("chilkat.support");
$mailman->put_PopPassword("****");
$mailman->put_PopSsl(1);
$mailman->put_MailPort(995);

#  Use our certificate, which is already installed
#  in our current-user certificate store on the computer.
$clientCert = new chilkat::CkCert();
$success = $clientCert->LoadByCommonName("Chilkat Software, Inc.");
if ($success != 1) {
    print $clientCert->lastErrorText() . "\n";
    exit;
}

#  Note: The GMail POP3 server does not require that you
#  have a client cert.  This example only demonstrates
#  how you may use a client certificate.  Typically,
#  higher-security systems may require a client-side SSL cert.
$mailman->SetSslClientCert($clientCert);

#  Establish a POP3 connection:
$success = $mailman->Pop3BeginSession();
if ($success != 1) {
    print $mailman->lastErrorText() . "\n";
    exit;
}

#  Let's look at the LastErrorText to see the details
#  of the successful connection.  We should see our cert:
print $mailman->lastErrorText() . "\r\n";

#  OK, now examine the server's cert:

$serverCert = $mailman->GetPop3SslServerCert();
if ($serverCert eq null ) {
    print "No server cert available." . "\n";
}
else {
    print "Server SSL certificate:" . "\r\n";
    print $serverCert->subjectDN() . "\r\n";

    #  Was the server certificate verified?
    #  It's not necessarily an error if the SSL Server cert is not verified.
    if ($mailman->get_Pop3SslServerCertVerified() == 1) {
        print "Server SSL certificate was verified." . "\r\n";
    }
    else {
        print "Server SSL certificate was NOT verified!" . "\r\n";
    }

}


 

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.