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.
import sys import chilkat # The mailman object is used for sending and receiving email. mailman = chilkat.CkMailMan() # Any string argument automatically begins the 30-day trial. success = mailman.UnlockComponent("30-day trial") if (success != True): print mailman.lastErrorText() sys.exit() # 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): print mailman.lastErrorText() sys.exit() strCharset = "ansi" # Send the CPWD command and get the response. # Do not include a trailing CRLF (carriage-return line-feed) in the command string. bEncodeBase64 = False strResponse = mailman.smtpSendRawCommand("CPWD",strCharset,bEncodeBase64) if (strResponse == None ): print mailman.lastErrorText() sys.exit() # Expecting a 334 response... if (mailman.get_LastSmtpStatus() != 334): print strResponse sys.exit() # Now send the existing login/password, base64-encoded: bEncodeBase64 = True # Send the existing login: strResponse = mailman.smtpSendRawCommand("mySmtpLogin",strCharset,bEncodeBase64) if (strResponse == None ): print mailman.lastErrorText() sys.exit() # Expecting a 334 response... if (mailman.get_LastSmtpStatus() != 334): print strResponse sys.exit() # Send the existing password: strResponse = mailman.smtpSendRawCommand("mySmtpPassword",strCharset,bEncodeBase64) if (strResponse == None ): print mailman.lastErrorText() sys.exit() # Expecting a 334 response... if (mailman.get_LastSmtpStatus() != 334): print strResponse sys.exit() # Send the new password: strResponse = mailman.smtpSendRawCommand("myNewSmtpPassword",strCharset,bEncodeBase64) if (strResponse == None ): print mailman.lastErrorText() sys.exit() # Expecting a 250 response... if (mailman.get_LastSmtpStatus() != 250): print strResponse sys.exit() print "SMTP password changed!" success = mailman.CloseSmtpConnection() if (success != True): print "Connection to SMTP server not closed cleanly." |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.