[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Capturing Email on smtp & pop3 ports

I need to  capture all email to and from a computer, is there an easy way to do this, I was thinking of port capturing? I see that some antivirus programs capture the mail ...
1 Solution
TheRealLokiSenior DeveloperCommented:
If you want to "intercept" the email before it reaches the computer, and before it is sent, then 1 way is to to change the settings in the email clients. You can get your software to do this automacially on setup/run

This is how earlier antivirus software did it. Your software changes the outlook/outlook express/other client, settings to point to localhost (same computer) on different ports.

e.g. change
pop.someserver.com           port 110
smtp.someserver.com         port 25
localhost                         port 2110 (your software listening to this port)
localhost                         port 2025 (your software listening to this port)

There are several ways to implement this
when changing the account settings in the email client, use a different local port for each account (e.g. 2110 - 2210 range)
That way you know that if the email client talks to localhost: 2110 it is the "first pop account" and really wants to talk to ":someserver.com:110"
and if the email client talks to localhost: 2111 it is the "second pop account" and really wants to talk to "adifferentserver:110"

b) if you just want to check all incoming (pop3) mail, you only need to change the email clients settings
    host: someserver.com
    port: 110
    username: bob
    host: localhost
    port: 2110
    username: someserver.com:bob

when your software receives the connect form the email client on port 2110 it sends back a welcome message, and then waits for the email client to send the "USER" command
when it gets the "USER" command, it strips out the "real server name" (someserver.com) and the "username" (bob)
It then makes the real connection to "someserver.com" and sends the "USER bob" command
from then on, it just relays data both ways. When it does a "RETR" command (DL email), it will save it locally and check for viruses, before relaying it to the email client

These days, you can do a better hook into the POP3: and  SMTP:  protocols in windows, but I'm not sure how to do that

I don't have any more info on this for you, but hopefully it's enough to get you started.

If you want to see the email data, but not intercept/interfere with it, then you will need a packet sniffer.
You can use Etherel for this, it comes with libraries that can be used by delphi

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now