Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SmtpServer as a SMTP Filter for SPAM #216

Open
alijundi opened this issue Apr 16, 2024 · 1 comment
Open

Using SmtpServer as a SMTP Filter for SPAM #216

alijundi opened this issue Apr 16, 2024 · 1 comment

Comments

@alijundi
Copy link

Hi @cosullivan

I thank you for this wonderful library,

I want to use it as follows in my company. Email comes in to the SMTP Server using this library and then forwarded to another SMTP server where emails are stored.

It will check the incoming message if it is spam and modify the subject by adding SPAM before it and then it will immediatly forward it to the specified SMTP server.

Can you direct me on how to implement this. I believe it should not be too hard. Don't worry about the SPAM function it will will take the TO/FROM/SUBJECT/BODY of the message to decide whether it is SPAM or not and then return true/false to the calling check function.

@mormegil-cz
Copy link

It seems fairly straightforward, doesn’t it? You just start the SmtpServer and configure an appropriate IMessageStore (and possibly a IMailboxFilter if you know existing recipients). The store implementation will just forward the message to the destination SMTP server (using e.g. MailKit’s SmtpClient).

Even though you might want to use store-and-forward instead of directly forwarding synchronously inside the incoming SMTP transaction, I think. I.e. create a simple Sqlite (or any other) database and store all incoming messages there in the IMessageStore implementation. Then, have another worker asynchronously fetch the messages from the database and send them to the destination SMTP server.

In fact, I’m working on something very similar, even though not specifically as a spam filter.

(P.S. This might better be a discussion instead of an issue?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants