Sample code for 30+ languages & platforms
Tcl

Add a PFX Source to MailMan for Decryption

See more POP3 Examples

Demonstrates the Chilkat MailMan.AddPfxSourceFile method, which adds a PFX/PKCS#12 file to the MailMan object's internal list of sources used for locating certificates and private keys — for example, to decrypt S/MIME email downloaded from the server. The second argument is the PFX password. This example configures a POP3 connection and registers a PFX source.

Background: When MailMan downloads an encrypted (S/MIME) message, it needs the recipient's private key to decrypt it. On Windows and macOS the OS certificate stores are searched automatically, but when the key lives in a standalone PFX file — common on Linux or in server deployments — AddPfxSourceFile tells MailMan where to find it. A PFX bundles the certificate and its private key in one password-protected file.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

#  Demonstrates the MailMan.AddPfxSourceFile method, which adds a PFX/PKCS#12 file to the
#  MailMan object's internal list of sources used for locating certificates and private
#  keys (for example, to decrypt downloaded S/MIME email).  The 2nd argument is the PFX
#  password.

set mailman [new_CkMailMan]

#  Configure the POP3 server connection.
CkMailMan_put_MailHost $mailman "pop.example.com"
CkMailMan_put_MailPort $mailman 995
CkMailMan_put_PopSsl $mailman 1
CkMailMan_put_PopUsername $mailman "user@example.com"
CkMailMan_put_PopPassword $mailman "myPassword"

#  Provide a PFX so that encrypted emails downloaded from the server can be decrypted.

set success [CkMailMan_AddPfxSourceFile $mailman "qa_data/certs/decryption.pfx" "pfx_password"]
if {$success == 0} then {
    puts [CkMailMan_lastErrorText $mailman]
    delete_CkMailMan $mailman
    exit
}

puts "Added the PFX certificate/private-key source."

#  Note: The path "qa_data/certs/decryption.pfx" is a relative local filesystem path,
#  relative to the current working directory of the running application.

delete_CkMailMan $mailman