Unicode C
Unicode C
Send an SMTP RSET Command
See more SMTP Examples
Demonstrates the Chilkat MailMan.SmtpReset method, which sends an SMTP RSET command to the server. RSET resets the server-side state of the current mail transaction. This example opens a connection, sends RSET, and closes.
Background: During an SMTP session a message is built up across
MAIL FROM and RCPT TO commands. If you need to abandon that partially-specified transaction — say an error occurred midway — RSET clears it without dropping the connection, so the same authenticated session can start a fresh message. It's a lightweight way to recover in-session rather than reconnecting.Chilkat Unicode C Downloads
#include <C_CkMailManW.h>
void ChilkatSample(void)
{
BOOL success;
HCkMailManW mailman;
success = FALSE;
// Demonstrates the MailMan.SmtpReset method, which sends an SMTP RSET command to the server.
// RSET resets the server-side state of the current mail transaction.
mailman = CkMailManW_Create();
// Configure the SMTP server connection.
CkMailManW_putSmtpHost(mailman,L"smtp.example.com");
CkMailManW_putSmtpPort(mailman,465);
CkMailManW_putSmtpSsl(mailman,TRUE);
CkMailManW_putSmtpUsername(mailman,L"user@example.com");
CkMailManW_putSmtpPassword(mailman,L"myPassword");
// Open the connection.
success = CkMailManW_OpenSmtpConnection(mailman);
if (success == FALSE) {
wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
CkMailManW_Dispose(mailman);
return;
}
// Reset the current SMTP mail transaction.
success = CkMailManW_SmtpReset(mailman);
if (success == FALSE) {
wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
CkMailManW_Dispose(mailman);
return;
}
success = CkMailManW_CloseSmtpConnection(mailman);
if (success == FALSE) {
wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
CkMailManW_Dispose(mailman);
return;
}
wprintf(L"Sent SMTP RSET.\n");
CkMailManW_Dispose(mailman);
}