Visual C++ Examples

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

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

Using SmtpSendRawCommand to Change Password

Demonstrates how to use the SmtpSendRawCommand method to change the SMTP user account's password for an SMTP server that supports the non-standard CPWD command.

Note: The SmtpSendRawCommand method is not yet released. To get a pre-release, send email to support@chilkatsoft.com.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
FreeBSD C++ Libraries
HP-UX C++ Libraries
BlackBerry QNX C++ Libraries
#include <CkMailMan.h>

void ChilkatSample(void)
    {
    //  The mailman object is used for sending and receiving email.
    CkMailMan mailman;

    //  Any string argument automatically begins the 30-day trial.
    bool success;
    success = mailman.UnlockComponent("30-day trial");
    if (success != true) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    //  Set the SMTP server.
    mailman.put_SmtpHost("smtp.chilkatsoft.com");

    //  Set the SMTP login/password (if required)
    mailman.put_SmtpUsername("myUsername");
    mailman.put_SmtpPassword("myPassword");

    //  Connect and authenticate:
    success = mailman.OpenSmtpConnection();
    if (success != true) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    const char * strCharset;
    strCharset = "ansi";

    bool bEncodeBase64;

    //  Send the CPWD command and get the response.
    //  Do not include a trailing CRLF (carriage-return line-feed) in the command string.

    const char * strResponse;

    bEncodeBase64 = false;
    strResponse = mailman.smtpSendRawCommand("CPWD",strCharset,bEncodeBase64);
    if (strResponse == 0 ) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    //  Expecting a 334 response...
    if (mailman.get_LastSmtpStatus() != 334) {
        printf("%s\n",strResponse);
        return;
    }

    //  Now send the existing login/password, base64-encoded:
    bEncodeBase64 = true;

    //  Send the existing login:
    strResponse = mailman.smtpSendRawCommand("mySmtpLogin",strCharset,bEncodeBase64);
    if (strResponse == 0 ) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    //  Expecting a 334 response...
    if (mailman.get_LastSmtpStatus() != 334) {
        printf("%s\n",strResponse);
        return;
    }

    //  Send the existing password:
    strResponse = mailman.smtpSendRawCommand("mySmtpPassword",strCharset,bEncodeBase64);
    if (strResponse == 0 ) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    //  Expecting a 334 response...
    if (mailman.get_LastSmtpStatus() != 334) {
        printf("%s\n",strResponse);
        return;
    }

    //  Send the new password:
    strResponse = mailman.smtpSendRawCommand("myNewSmtpPassword",strCharset,bEncodeBase64);
    if (strResponse == 0 ) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    //  Expecting a 250 response...
    if (mailman.get_LastSmtpStatus() != 250) {
        printf("%s\n",strResponse);
        return;
    }

    printf("SMTP password changed!\n");

    success = mailman.CloseSmtpConnection();
    if (success != true) {
        printf("Connection to SMTP server not closed cleanly.\n");
    }


    }

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

Mail Component · .NET Mail Component · XML Parser