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
|
Using SmtpSendRawCommand to Change PasswordDemonstrates 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.
LOCAL loMailman LOCAL lnSuccess LOCAL lcStrCharset LOCAL loBEncodeBase64 LOCAL lcStrResponse * The mailman object is used for sending and receiving email. loMailman = CreateObject('Chilkat.MailMan2') * Any string argument automatically begins the 30-day trial. lnSuccess = loMailman.UnlockComponent("30-day trial") IF (lnSuccess <> 1) THEN ? loMailman.LastErrorText QUIT ENDIF * Set the SMTP server. loMailman.SmtpHost = "smtp.chilkatsoft.com" * Set the SMTP login/password (if required) loMailman.SmtpUsername = "myUsername" loMailman.SmtpPassword = "myPassword" * Connect and authenticate: lnSuccess = loMailman.OpenSmtpConnection() IF (lnSuccess <> 1) THEN ? loMailman.LastErrorText QUIT ENDIF lcStrCharset = "ansi" * Send the CPWD command and get the response. * Do not include a trailing CRLF (carriage-return line-feed) in the command string. loBEncodeBase64 = .F. lcStrResponse = loMailman.SmtpSendRawCommand("CPWD",lcStrCharset,llBEncodeBase64) IF (lcStrResponse = NULL ) THEN ? loMailman.LastErrorText QUIT ENDIF * Expecting a 334 response... IF (loMailman.LastSmtpStatus <> 334) THEN ? lcStrResponse QUIT ENDIF * Now send the existing login/password, base64-encoded: loBEncodeBase64 = .T. * Send the existing login: lcStrResponse = loMailman.SmtpSendRawCommand("mySmtpLogin",lcStrCharset,llBEncodeBase64) IF (lcStrResponse = NULL ) THEN ? loMailman.LastErrorText QUIT ENDIF * Expecting a 334 response... IF (loMailman.LastSmtpStatus <> 334) THEN ? lcStrResponse QUIT ENDIF * Send the existing password: lcStrResponse = loMailman.SmtpSendRawCommand("mySmtpPassword",lcStrCharset,llBEncodeBase64) IF (lcStrResponse = NULL ) THEN ? loMailman.LastErrorText QUIT ENDIF * Expecting a 334 response... IF (loMailman.LastSmtpStatus <> 334) THEN ? lcStrResponse QUIT ENDIF * Send the new password: lcStrResponse = loMailman.SmtpSendRawCommand("myNewSmtpPassword",lcStrCharset,llBEncodeBase64) IF (lcStrResponse = NULL ) THEN ? loMailman.LastErrorText QUIT ENDIF * Expecting a 250 response... IF (loMailman.LastSmtpStatus <> 250) THEN ? lcStrResponse QUIT ENDIF =MESSAGEBOX("SMTP password changed!") lnSuccess = loMailman.CloseSmtpConnection() IF (lnSuccess <> 1) THEN =MESSAGEBOX("Connection to SMTP server not closed cleanly.") ENDIF |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser