davidmoten / subethasmtp

SubEtha SMTP is a Java library for receiving SMTP mail
Other
149 stars 40 forks source link

Would like a way to block connections by client IP #97

Closed devondragon closed 1 year ago

devondragon commented 1 year ago

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?

davidmoten commented 1 year ago

Yep, just set a SessionHandler in the builder.

devondragon commented 1 year ago

Got it! Thank you!