DelphiFeeds.com

  • Dashboard
  • Popular Stories
  • Trending Stories
  • Feeds
  • Login
Trending now

Incredibly Powerful Enhanced Terminal And Network Toolkit For Windows Is Built In Delphi

Learn How To Use C++ Explicit Virtual Overrides In Windows Development

Learn Python With The 5 Best Python GUI Libraries Video

Trial – TMS VCL WebGMaps

Trial – TMS VCL UI Pack

Trial – TMS VCL Cloud Pack

Trial – TMS VCL Chart

Trial – TMS Scripter

Brook Framework

Get These Visually Stunning FireMonkey Styles Free To Enhance User Experience In Your Delphi Apps

VCL Styles: Master The Secrets Of Beautiful Modern Apps In Windows 10

grep for Delphi .dproj file containing copy commands for certain DLLs

Powerful Cross Platform Multitrack Music Recording Software Built In Delphi FireMonkey

Ultra-Fast Enterprise-Grade List And Label Reporting Tool For Delphi

Learn An Efficient Way to Use C++ Extern Templates For Robust Windows Development

Gmail, POP3 and Indy

1
Marshall Fryman Marshall Fryman 11 years ago in Coding, Delphi, Indy 0
In my ever expanding need for dealing with the outside world, I've discovered a quirky little thing about Indy 10. When using the TIdPOP3 component with Gmail, you have to manually call DisconnectNotifyPeer or delete commands are ignored. I suppose this isn't quirky as much as not really documented any place I was able to find. Let's backup and start at the beginning, shall we?

I have a Windows service that polls a POP3 account looking for messages that it can import into a DB. It has all sorts of fun rules that can be assigned to discover what needs to be imported, what database it goes into, etc. At any rate, this code has been merrily chugging away on both Yahoo and SmarterMail servers with nary a hiccup. I recently needed to watch a Google domain app e-mail address and didn't think much of it.

Of course, in order to do so you have to implement SSL for POP3. As I've posted in the past, this is not really much of an issue, you simply create the TIdSSLIOHandlerSocketOpenSSL object and assigned it to the IOHandler like so:
Pop3Srv.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(Pop3Srv);
Pop3Srv.UseTLS := utUseImplicitTLS;


Anyway, all was proceeding swimmingly until I retrieved the first message. In my case, I automatically delete any e-mail that matches my rules so it will not be imported a second time. This works fine with Yahoo and SmarterMail. You just call DeleteMessage(msgNumber) and voila, away it goes. With Gmail, no such luck.

Gmail actually has a three different settings under POP3. One keeps messages in the inbox after reading via POP, one archives it and one deletes it. Thinking this option was set wrong, I tried all three options... repeatedly... still no luck. I tried searching pretty extensively on this one and finally found the clue with RFC 1939. Gmail honors the "you must notify me you are quitting or I will not delete anything" rule that 1939 dictates.
When the client issues the QUIT command from the TRANSACTION state, the POP3 session enters the UPDATE state. (Note that if the client issues the QUIT command from the AUTHORIZATION state, the POP3 session terminates but does NOT enter the UPDATE state.) If a session terminates for some reason other than a client-issued QUIT command, the POP3 session does NOT enter the UPDATE state and MUST not remove any messages from the maildrop.


After checking the code for the IdPOP3, it turns out calling Free does not issue the QUIT command. It makes sense for it not to do so. What if you wanted to avoid the UPDATE state? It was just surprising that some mail servers worked without this command and some required it.

At any rate, I hope this helps someone else who's working with POP3 commands.

Trending Stories

  • Incredibly Powerful Enhanced Terminal And Network Toolkit For Windows Is...

  • Learn How To Use C++ Explicit Virtual Overrides In Windows...

  • Learn Python With The 5 Best Python GUI Libraries Video

  • Trial – TMS VCL WebGMaps

  • Trial – TMS VCL UI Pack

Embarcadero GetIt

  • Brook Framework

    Microframework which helps to develop web Pascal applications.

  • Trial - TMS Scripter

    Add the ultimate flexibility and power into your apps with native Pascal or Basic scripting and […]

  • Trial - TMS VCL Chart

    DB-aware and non DB-aware feature-rich charting components for business, statistical, financial […]

  • Trial - TMS VCL Cloud Pack

    TMS VCL Cloud Pack is a Delphi and C++Builder component library to seamlessly use all major cloud […]

  • Trial - TMS VCL UI Pack

    Create modern-looking & feature-rich Windows applications faster with well over 600 components […]

  • Learn Delphi Programming
  • Learn C++
  • Embarcadero Blogs
  • BeginEnd.net
  • Python GUI
  • Firebird News
  • Torry’s Delphi Pages
Copyright DelphiFeeds.com 2021. All Rights Reserved
Embarcadero
Login Register

Login

Lost Password

Register

Lost Password