How to delete emails based on subject?
Hi,
Theres a way to delete all emails based on subject on linux? I need remove more than 100k os mails with subject: Mail delivery failed: returning message to sender |
what kind of mailer do you have? For example using thunderbird you can easily create a filter to do that.
|
Hi
Thanks for attention I need remove this via shell from the server... I'm using something like: find . -type f -exec grep -i "Mail delivery failed: returning message to sender" -exec rm -v {} \; grep: Mail delivery failed: returning message to sender: Arquivo ou diretório não encontrado find $1 . -type f -exec grep -i "Mail delivery failed: returning message to sender" {} \; | xargs rm -v $2 for RM in $(find . -type f -exec grep -i "Mail delivery failed: returning message to sender" {} \;); do rm -v $RM ; done But i can't figure out how to remove the file. Just how to find the subject... :confused: |
Quote:
IF you had thunderbird, you could "see" where in your Tbird setup these messages occur using: Code:
find .thunderbird/ -type f -exec grep -il "Mail delivery failed: returning message to sender" {} \; Thunderbird (all of mozilla-land, it seems) uses sqllite databases for message storage, so nuking them should be done from inside the Thunderbird program. Code:
file .thunderbird/uvpc4uva.default/global-messages-db.sqlite |
if i can think in high voice.... i think that in your place i do a script based on:
cd maildir/folder grep -in "subject" * |grep -in "subject to delete" >a.txt If all work fine you will get into "a.txt"the list of matching files. My script can contain error there is not intended to copy/paste, is to give a idea about direction that i take in your place. |
Thanks!
Hi people.
Maybe i not expressing myself properly. I'm using centos with exim. No email client. Thanks for efforts. Quote:
Hi schlabs Thanks for help! That was what i was looking for. Now i can take the name of mailfile by the subject. Soon as possible i'll make a script and post here. I was a little confuse how to take the name of file by subject. But with your help now i can figure out how to. :D |
Quote:
To delete all queued messages containing a certain string in the body < for exim only |
Quote:
The second grep make the real filter showing only the files that matching "spam to erase"or "mail returned" or etc. After both grep you will get a list of filenames that meet your requirements. Some like : mailfile12345:25:Subject: mail returned or mail_filename:number of line:matching text A last step is redirect the screen to any file, so you will get a list of files to erase. Actually i do some similar, i create a folder SPAM email. When the user put a email here i look (grep) email provider of spammer, ip provider of spammer, and domains involved. This automatically update the spam filter. Best Regards |
Hi
I found a way with this command. To remove all in the current folder. grep -in "Mail delivery failed: returning message to sender" * | grep -in "Mail delivery failed: returning message to sender" | rm -rf $(awk -F ":" '{print $2}') Thanks for the help. |
Sorry guy, do you mean the same grep two times and piped into an rm?
I would rather suggest you to look for another solution, this is not the right way. |
Quote:
Any suggestion?? Later i'll try something... |
I did something similar myself recently using procmail, one of the best mail filtering programs out there by looping through all e-mails and executing procmail on them and removing an e-mail afterwards like this:
Code:
#!/usr/bin/env sh Code:
:0: |
All times are GMT -5. The time now is 12:13 AM. |