-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Limit the amount of mails Mailhog saves #74
Comments
thanks @oers 👍 good idea! |
Is there any known progress on this? |
As a workaround: call periodically |
I've started to work on this item as it's seems to be very critical for me. For now, to make thinks easy, I'm implementing limit based on number of messages for InMemory and MongoDB storage. Maildir needs more work. I will submit the PR in a few days. Regards. |
Addressed on PR #244 Regards. |
Nice work @allangood ! |
Is this merged yet? |
No, isn't. But I've forked this project and published a version with this change on my account. |
@allangood is there a docker image for this? |
Hi @trajano , you can use the Docker file available on my repository to build it. It uses the latest version of Alpine. |
@allangood what's the URL for the repository? I can't find it in docker hub. Oh I just read it carefully, you didn't publish it to Hub then. |
This needs to be merged, because without it, automatic periodical tests are not possible with MailHog. The memory consumption will kill it sooner or later. It's just a matter of time and amount of mails sent. |
Sorry guys, but I never publish it on Docker Hub. I didn't want to "compete" with the original repository... |
I see there is lot of value in automatic clean up of emails as a feature in mailhog. We use mailhog as a service for development and automated functional test practice. Wiping all mails periodically causing tests to fail as our test script checks back to mailhog if mails received as expected. So I would like the clean up procedure as configurable like There are options how to implement Any opinion to add/eliminate these options to come to a better decision? |
I would not expect mailhog to implement a whole scheduler just for this one task, if not for something more useful anyway. |
@sgohl, I hope you are referring to add a query parameter older_than to GET /api/v2/messages api. Right? Or you meant to say DELETE? By saying "not expect mailhog to implement a whole scheduler", I guess you are preferring to introduce the option 4 which provides API to delete older_than (in minutes) emails. Let the user decide how they want to call the delete rest api. Let me know if I did not write option 4? |
yea ok sry, I think I got your 4th option wrong at first. Reading again, it's exactly what I meant |
@sgohl @ian-kent I am thinking about implementing it. But I do not see any recent PR got accepted. |
hello! 2 y.ago... Any news? Script or crontab with api or other - very bad idea. |
Very interested in this PR what do we need to do to make it happen? I'd be happy to update the PR to resolve conflicts if necessary. |
Interested to see @allangood 's PR make it in eventually. Our needs are much more basic, so for now I'm using @savinov 's DELETE method overnight daily just with this in my crontab
(placed here for any other n00bs like me, using everything out of the box default, who might need to google a few things to figure out how to "just run DELETE on the API periodically") |
Any update on this feature? Limit on messages/memory would be helpful |
A workaround :
docker-compose.yml : version: '3'
services:
mailhog:
restart: always
image: mailhog/mailhog
container_name: mailhog
environment:
MH_STORAGE: maildir
MH_MAILDIR_PATH: /home/mailhog/mails
MH_API_BIND_ADDR: 0.0.0.0:8026
MH_UI_BIND_ADDR: 0.0.0.0:8026
MH_SMTP_BIND_ADDR: 0.0.0.0:8025
ports:
- "8025:8025"
- "8026:8026" crontab (test only with macOs) # delete mailhog data
* * * * * ~/.scripts/clean-mailhog.sh ~/.scripts/clean-mailhog.sh #!/bin/bash
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin
CONTAINER_NAME="mailhog"
KEPT_FILE_COUNT=100
MH_MAILDIR_PATH=$(docker exec $CONTAINER_NAME sh -c 'echo $MH_MAILDIR_PATH')
MH_HOME=$(docker exec $CONTAINER_NAME sh -c 'echo $HOME')
((KEPT_FILE_COUNT+=1))
docker exec $CONTAINER_NAME sh -c "ls -t $MH_MAILDIR_PATH/|tail -n +$KEPT_FILE_COUNT|xargs -I @ rm $MH_MAILDIR_PATH/@"
docker exec $CONTAINER_NAME sh -c "echo 'last cleanup at $(date)' > $MH_HOME/cleanup.log" |
I have a long running Installation for a test environment.
To speed up the reaction times of the gui I would like to:
and/or
The text was updated successfully, but these errors were encountered: