Delete all emails from a specific user #4303
-
Is there an easy way to delete all emails in a mailbox originating from a particular sender email. The emails have already been delivered, so its not a spam filter. Something like |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Something like this should work: # get mails from sender and verify
grep '^From: Foo Bar <foo@example>' data/maildata/DOMAIN/USER/cur
# get mails from sender and delete
grep -l '^From: Foo Bar <foo@example>' data/maildata/DOMAIN/USER/cur | xargs rm |
Beta Was this translation helpful? Give feedback.
-
Thanks ! |
Beta Was this translation helpful? Give feedback.
-
To prevent getting some mails in the first place, you can use header checks. Here is an # DISCARD/REJECT mails based on header
# http://www.postfix.org/header_checks.5.html
echo '/^Subject:.*Bitcoin Investment.*Earn.*/ DISCARD spam' >> /etc/postfix/maps/header_checks.pcre
echo '/^Subject:.*Invest In Bitcoin.*/ DISCARD spam' >> /etc/postfix/maps/header_checks.pcre This can be adjusted for senders as well. |
Beta Was this translation helpful? Give feedback.
-
Awesome. Thanks. How does this differ from sieve ?
…On Sat, 4 Jan 2025 at 11:50, Casper ***@***.***> wrote:
To prevent getting some mails in the first place, you can use header
checks. Here is an user-patches.sh example, how to discard mails with a
certain subject:
# DISCARD/REJECT mails based on header# http://www.postfix.org/header_checks.5.htmlecho '/^Subject:.*Bitcoin Investment.*Earn.*/ DISCARD spam' >> /etc/postfix/maps/header_checks.pcreecho '/^Subject:.*Invest In Bitcoin.*/ DISCARD spam' >> /etc/postfix/maps/header_checks.pcre
This can be adjusted for senders as well.
—
Reply to this email directly, view it on GitHub
<#4303 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMNNHGW6YIWN747JVLRAZZT2I7DITAVCNFSM6AAAAABUR3RXN6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNZTGI4DSMQ>
.
You are receiving this because you authored the thread.Message ID:
<docker-mailserver/docker-mailserver/repo-discussions/4303/comments/11732892
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
I don't know, I've never used sieve. It's probably just another way to achieve the same. I think this way, an email is not accepted at all. While with sieve, the mail is accepted and later discarded/deleted? |
Beta Was this translation helpful? Give feedback.
Something like this should work: