These are chat archives for IndySockets/Indy

Nov 2018
Marcos Douglas B. Santos
Nov 07 2018 01:01
What is the correct way to delete emails on server?
Sometimes the user wants just to see the emails (on a grid) but maintain them on the server. In that case I do not call .Disconnect - accordingly to the manual. Otherwise, if he/she wants to download and delete on server, I call Disconnect. However, it looks not working... all the time.
Remy Lebeau
Nov 07 2018 01:02
@mdbs99 POP3 or IMAP?
Remy Lebeau
Nov 07 2018 01:49
@mdbs99 Either way, you are going about this the wrong way. You should always call Disconnect(), as it ends the current session gracefully, in both POP3 and IMAP, and then closes the socket. In POP3, ending the session gracefully automatically deletes any emails that were previously marked for deletion with the TIdPOP3.Delete() method. They are not actually deleted until Disconnect() is called (emails marked for deletion can be unmarked by calling TIdPOP3.Reset() before disconnecting). In IMAP, emails are marked for deletion using the TIdIMAP4.DeleteMsgs() or TIdIMAP4.UIDDeleteMsg...() methods, and then deleted only when the mailbox is expunged with the TIdIMAP4.ExpungeMailBox() method, not Disconnect()(emails marked for deletion can be unmarked by calling TIdIMAP4.StoreFlags()or TIdIMAP4.UIDStoreFlags() to remove the mfDeleted flag). So, if you don't want to delete emails from the server, then simply don't mark them for deletion to begin with. Nothing in the POP3 or IMAP protocols requires you to delete emails from the server.
Nov 07 2018 09:52
On IMAP some MailServer do delete E-Mails, which are marked as deleted, on their own... after "some" time. And consider if multiple devices connects to that mailbox that they could trigger the deleting of marked as delted mails.
Nov 07 2018 10:14
what is TIdReplySMTP? How to use it?
Marcos Douglas B. Santos
Nov 07 2018 11:10
@rlebeau it's POP3 (sorry). In my mind I should always use Disconnect, however it was deleting all emails that were read... I guess all emails that are read are marked for deletion by default - Am I wrong?
I'll try to use Connect, read all emails, call Reset, then Disconnect.
For deletion, I'll use TIdPOP3.Delete() in a loop, then Disconnect. But will this always work doesn't matter the service - for example, using GMail?
Remy Lebeau
Nov 07 2018 17:19
@mdbs99 in standard POP3, emails are marked for deletion ONLY when deleted explicitly by the client. HOWEVER, some providers, like Gmail, have options to control that behavior in POP3. For instance, in Gmail's settings (Settings > Forwarding and POP/IMAP > POP Download), the "When messages are accessed with POP" option can be set to "Delete Gmail's copy". There is no way to know for sure on the client side how specifically a POP3 server will react to accessing emails. What Gmail does is non-standard behavior. This is one of the many reasons why you really should be using IMAP instead of POP3. POP3 was never intended for mailbox management, IMAP is.