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

[DONOTMERGE] Add the ability to keep mail delivery under a threshold (rate limit) and resend when the relay falls below the threshold again. #168

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

barais
Copy link

@barais barais commented Nov 25, 2024

When you have a huge amount of mail to deliver, you can't release the queue at once and let the server maximize the outgoing mail throughput ! The result will be: you'll get blacklisted from a lot of MX servers.
That's why you should take care of it and do traffic shaping

Many smtp providers (even those from universities) impose threshold values in terms of the number of messages sent per (message/mins or per message/hour) and the number of recipients...

As a result, it is sometimes required to stay below these thresholds. Particularly when emails are sent by applications. This PR provides a small extension to this great smtprelay project to add this feature. I don't think this PR should be merged because it goes against the original spirit of keeping the code very small without too many dependencies. The idea of the PR is undoubtedly to keep a history of this addition, which is so useful to others, but it can be closed without comment.

[1] #155
[2] Dependencies to otter and go-limiter
[3] Close to https://wiki.deimos.fr/Postfix:_limit_outgoing_mail_throttling

@decke
Copy link
Owner

decke commented Dec 5, 2024

Thanks for the PR! Ratelimiting is definitely a case where smtprelay is not the right tool anymore. One of the main concepts is to be as transparent as possible so it needs to forward any errors from upstream SMTP and should not store & forward mails at all. Following that principle if the upstream SMTP decides to ratelimit us we just forward the error to the client and it's the clients task to handle this (eg. retry later).

Theoretically one could write a smtpqueue which does exactly the opposite: receive the mail, store it locally, try to periodically send it to the STMP server (respecting ratelimits, handle errors etc.) - but then you're basically a classic MTA.

@decke
Copy link
Owner

decke commented Dec 5, 2024

I still think ratelimiting could be useful and fit into smtprelays design but then in a way that we just block the client for a short period (eg. seconds) before we contact the upstream SMTP. From a concept point of view this might fit very well into the connectionChecker to block before the HELO message.

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

Successfully merging this pull request may close these issues.

2 participants