Xbase++
Xbase++
SMTP Send Raw Command
Demonstrates how to send a raw command to the SMTP server after the connecting and authenticating.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oMailman
LOCAL cResponseStr
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oMailman := CreateObject("Chilkat.MailMan")
oMailman:SmtpHost := "smtp.mail.us-west-2.awsapps.com"
oMailman:SmtpSsl := 1
oMailman:SmtpPort := 465
nSuccess := oMailman:SmtpConnect()
IF (nSuccess == 0)
? oMailman:LastErrorText
oMailman:destroy()
RETURN
ENDIF
oMailman:SmtpUsername := "john@example.com"
oMailman:SmtpPassword := "the_password"
nSuccess := oMailman:SmtpAuthenticate()
IF (nSuccess == 0)
? oMailman:LastErrorText
oMailman:destroy()
RETURN
ENDIF
? "Authenticated!"
// Send the "EHLO" command again to get the multi-line response that includes the SMTP capabilities.
// The capabilities are the lines in the response that begin with "250-".
cResponseStr := oMailman:SmtpSendRawCommand("EHLO client.example.com", "utf-8", 0)
IF (oMailman:LastMethodSuccess == 0)
? oMailman:LastErrorText
oMailman:destroy()
RETURN
ENDIF
? cResponseStr
// A sample response:
// 250-smtp.us-west-2.mail.awsapps.com
// 250-8BITMIME
// 250-AUTH PLAIN LOGIN
// 250 Ok
oMailman:destroy()