React Native
React Native
End a POP3 Session Without Committing Deletions
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3EndSessionNoQuit method, which closes the POP3 connection without sending the QUIT command. Pending deletion marks are not committed — messages marked with DELE during the session remain in the mailbox. This example marks a message for deletion and then abandons the session so the deletion does not take effect.
Background: POP3's deferred-deletion model effectively gives you a transaction: marks made with
DELE are only applied when the session ends with QUIT. Ending without QUIT is therefore a rollback — useful if an error occurs mid-processing and you'd rather leave the mailbox untouched than risk deleting messages you failed to handle. Use Pop3EndSession when you do want the deletions committed.Chilkat React Native Downloads
import { MailMan } from '@chilkat/react-native'
async function chilkatExample() {
// Demonstrates the MailMan.Pop3EndSessionNoQuit method, which closes the POP3 connection
// WITHOUT sending the QUIT command. Pending deletion marks are not committed -- messages
// marked with DELE during the session remain in the mailbox.
const mailman = new MailMan();
// Configure the POP3 server connection.
mailman.mailHost = 'pop.example.com';
mailman.mailPort = 995;
mailman.popSsl = true;
mailman.popUsername = 'user@example.com';
mailman.popPassword = 'myPassword';
try {
await mailman.pop3BeginSessionAsync();
} catch {
console.log(mailman.lastErrorText);
return;
}
// Mark a message for deletion...
try {
await mailman.deleteByMsgnumAsync(1);
} catch {
console.log(mailman.lastErrorText);
return;
}
// ...but end the session without QUIT, so the deletion is NOT committed and the message
// remains in the mailbox.
try {
await mailman.pop3EndSessionNoQuitAsync();
} catch {
console.log(mailman.lastErrorText);
return;
}
console.log('Session closed without committing the pending deletion.');
}