Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 diretrio no encontrado
Code:
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
Not gonna work, but go ahead and see.
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" {} \;
do NOT do any -exec on anything found since it will nuke the folder it finds in and not the actual message.
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
.thunderbird/RanDOM.default/global-messages-db.sqlite: SQLite 3.x database, user version 30
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.
Maybe i not expressing myself properly. I'm using centos with exim. No email client. Thanks for efforts.
Quote:
Originally Posted by schlabs
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.
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.
Maybe i not expressing myself properly. I'm using centos with exim. No email client. Thanks for efforts.
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.
grep -in in human mode say: show me the name of the file and the line with matching string, and case insensitive. So with the first grep you will get all files with "subject" string, and will show the line of subject. So the first grep will show all emails subject and their filename.
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.
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.
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.
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
set -e
for dir in cur new; do
find $INPUTMAILDIR/$dir -type f | while read file; do
procmail < $file
rm $file
done
done
You need to add a correct rule to your ~/.procmailrc before running this script. The rule could look like this:
Code:
:0:
* ^Subject:.*Mail delivery failed: returning message to sender*
/dev/null
BTW, I also recommend procmail as an every-day filtering program for your e-mail. You can make it execute an arbitrary action based on e-mail sender, subject, body or attachments.
Last edited by average_user; 06-16-2015 at 11:02 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.