davidmoten / subethasmtp

SubEtha SMTP is a Java library for receiving SMTP mail

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Would like a way to block connections by client IP

devondragon opened this issue · comments

I just started using your wonderful fork of SubEthaMail in a project (replacing Apache James). I was wondering if there is an easy way to block clients from connecting by IP, or even just fail delivery based on IP. Part of my application essentially works as a basic dynamic firewall, where I track SMTP clients who make too many connections over a given time window, or who deliver too many mails with the same body, mails that fail some tests, etc… and then block those IPs in the SMTP server.

The MessageListener accept method only gets the to and from, and even the delivery method doesn’t seem to have any clear way to see the client IP. Maybe there’s something I’ve missed, or component closer to the actual server where I could do some filtering of incoming connections?

Yep, just set a SessionHandler in the builder.

Got it! Thank you!