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
Send 168-bit 3DES Encrypted EmailDownloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries Demonstrates how to send 3DES encrypted mail. // Send a 3DES encrypted email
void EmailExample(void)
{
CkMailMan mailman;
// Any string passed to UnlockComponent begins the 30-day trial.
bool unlocked = mailman.UnlockComponent("30-day trial");
if (!unlocked)
{
printf("Failed to unlock component\n");
return;
}
mailman.put_SmtpHost("mail.earthlink.net");
// Send a 3DES 168-bit encrypted email.
CkEmail email;
email.put_Body("This is the encrypted email body");
email.put_FromAddress("matt@chilkatsoft.com");
email.put_Subject("This is the email subject");
// Load a certificate from a file and use it for encrypting.
CkCert cert;
cert.LoadFromFile("myCert.cer");
// The To address must match the email address in the certificate:
email.AddTo("Chilkat Support","support@chilkatsoft.com");
// Check to make sure the certificate's email address matches.
CkString certEmailAddr;
cert.get_SubjectE(certEmailAddr);
if (!certEmailAddr.equals("support@chilkatsoft.com"))
{
printf("Certificate email address (%s) does not match recipient's email address.\n",
certEmailAddr.getString());
return;
}
// To send an encrypted email, only the public-key is required.
// Use the certificate and indicate that the email should be encrypted.
email.put_SendEncrypted(true);
email.SetEncryptCert(&cert);
// Use 3DES encryption.
CkCSP csp;
csp.SetProviderMicrosoftEnhanced();
csp.SetEncryptAlgorithm("3DES");
email.SetCSP(&csp);
// Send the email
if (!mailman.SendEmail(&email))
{
mailman.SaveLastError("errors.xml");
}
else
{
// The last error information will also contain information
// about how the email was encrypted when successful, so you can
// verify that what you expected to happen actually did happen.
mailman.SaveLastError("info.xml");
}
}
************************
The info.xml file will look something like this:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<ChilkatLog>
<SendEmail>
<SMTP_Connect>
<info>Connecting to SMTP server mail.earthlink.net:25</info>
<smtp_host>mail.earthlink.net</smtp_host>
<smtp_port>25</smtp_port>
<smtp_user>NULL</smtp_user>
<trying_auth_method>NONE</trying_auth_method>
<login_method>NONE or already authenticated</login_method>
<info>CONNECTED to ESMTP server mail.earthlink.net:25</info>
</SMTP_Connect>
<using_algorithm>3DES</using_algorithm>
<info>Using explicit certificate.</info>
<encryption_certificate>Thawte Freemail Member, support@chilkatsoft.com</encryption_certificate>
<certificate_store></certificate_store>
<logged_on_user>Matt Fausey</logged_on_user>
<csp>Microsoft Enhanced Cryptographic Provider v1.0</csp>
<alg_name>3DES</alg_name>
<alg_bits>168</alg_bits>
<encryptOid>1.2.840.113549.3.7</encryptOid>
<subject>This is the email subject</subject>
<from>matt@chilkatsoft.com</from>
<recipients>
<to>support@chilkatsoft.com</to>
</recipients>
<email_size>1622</email_size>
<info>Mail sent to 1 recipient</info>
</SendEmail>
</ChilkatLog>
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.