PowerBuilder
PowerBuilder
Send an SMTP NOOP Command
See more SMTP Examples
Demonstrates the Chilkat MailMan.SmtpNoop method, which sends an SMTP NOOP command to the server. NOOP does nothing except elicit a positive response, which is useful for keeping a connection alive or verifying it is still responsive. This example opens an SMTP connection, sends a NOOP, and closes.
Background: When holding an SMTP connection open across many sends (see
OpenSmtpConnection), an idle stretch can cause the server to time out and drop the socket. A periodic NOOP keeps the session active and confirms the server is still responding, so the next SendEmail doesn't fail on a silently-closed connection.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mailman
li_Success = 0
// Demonstrates the MailMan.SmtpNoop method, which sends an SMTP NOOP command to the server.
// NOOP does nothing except elicit a positive response, useful for keeping a connection
// alive or verifying it is still responsive.
loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
destroy loo_Mailman
MessageBox("Error","Connecting to COM object failed")
return
end if
// Configure the SMTP server connection.
loo_Mailman.SmtpHost = "smtp.example.com"
loo_Mailman.SmtpPort = 465
loo_Mailman.SmtpSsl = 1
loo_Mailman.SmtpUsername = "user@example.com"
loo_Mailman.SmtpPassword = "myPassword"
// Open the SMTP connection.
li_Success = loo_Mailman.OpenSmtpConnection()
if li_Success = 0 then
Write-Debug loo_Mailman.LastErrorText
destroy loo_Mailman
return
end if
// Send a NOOP to keep the connection alive.
li_Success = loo_Mailman.SmtpNoop()
if li_Success = 0 then
Write-Debug loo_Mailman.LastErrorText
destroy loo_Mailman
return
end if
li_Success = loo_Mailman.CloseSmtpConnection()
if li_Success = 0 then
Write-Debug loo_Mailman.LastErrorText
destroy loo_Mailman
return
end if
Write-Debug "SMTP NOOP succeeded."
destroy loo_Mailman