#! /usr/bin/env python import poplib M = poplib.POP3_SSL("mail.example.com", 995) M.user("firstname.lastname@example.org") M.pass_("password") for i in range(M.stat(), 0, -1): M.dele(i) M.quit()
To prompt for the password rather than storing it in the script, change
(getpass.getpass()) and add
Sources & Additional Examples:
poplib documentation: "On most servers deletions are not actually performed until QUIT (the major exception is Eudora QPOP, which deliberately violates the RFCs by doing pending deletes on any disconnect)."
/nix | Aug 04, 2020
Subscribe or visit the archives.