Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 11-19-2010, 08:45 AM   #1
Senior Member
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 75
Question Block Unwanted Email Recommendations

So I have a company that I've registered my email address with and sadly they wont unsubscribe me. I've tried over and over and they tell me they don't recognize my email address but clearly they're sending me promotional messages daily. I'm running Postfix 2.7.1 on my mail server and would like to know what's the best recommended way to block them? Should I block them by IP or should I block them via domain name? Obviously the domain is easily forged so I am guessing a range or specific IP would be the best, no?

Below are headers:

Return-Path: <>
Received: from ( [])
	by (Postfix) with ESMTP id 5CDF81405D7
	for <>; Thu, 18 Nov 2010 17:39:26 -0500 (EST)
X-MSFBL: Y2FybG9zQGlhbXVuaXguY29tQGJ1cmtldG93bkJpbmRpbmdAbmV3dG9uQmluZGlu
DomainKey-Signature: q=dns; a=rsa-sha1; c=nofws;;;
DKIM-Signature: v=1; a=rsa-sha1;;; c=simple/simple;
	q=dns/txt;; t=1290119966;
DKIM-Signature: v=1; a=rsa-sha1;;; c=simple/simple;
	q=dns/txt;; t=1290119966;
Received: from [] ([] helo=localhost.localdomain)
	by dc1bhmta02 (envelope-from <>)
	(ecelerity r(35835)) with ESMTP
	id 1C/9C-29605-E1BA5EC4; Thu, 18 Nov 2010 14:39:26 -0800
Message-ID: <1C.9C.29605.E1BA5EC4@dc1bhmta02>
Date: Thu, 18 Nov 2010 13:07:30 -0800
From: *******OMITTED*******
Reply-To: donotreply@************
To:  <>
X-Outgoing: newton
Subject: Carlos - Big Sale This Weekend! 
List-Unsubscribe: <>
X-PVIQ: 000088-000144-echo20-000000-742673
Mime-Version: 1.0
Content-Type: multipart/alternative;
As you can see in the headers I see two client IP's but I'm not sure which I should block and also how to do so in Postfix. Can anyone assist me in this issue?
Old 11-19-2010, 09:11 AM   #2
Registered: Feb 2010
Location: USA
Distribution: RHEL
Posts: 36

Rep: Reputation: 15
This isn't a postfix solution, but it will block the emails:

iptables -I INPUT -s -p tcp --dport 25 -j REJECT

That will reject any incoming traffic from that IP on port 25. You'll want to put it in your startup scripts to re-add the rule after reboots.
1 members found this post helpful.
Old 11-19-2010, 09:13 AM   #3
Senior Member
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 75
Thanks - that was voted as "helpful" but I'm only looking for Postfix specific solutions.
Old 11-20-2010, 05:52 AM   #4
Senior Member
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
Postfix has a "check_sender_access" feature which can accomplish this. From the documentation site:
Search the specified access(5) database for the MAIL FROM address, domain, parent domains, or localpart@, and execute the corresponding action
To implement this create a file for your reject list and add a line with the sender's email (from their header), with the word REJECT following it. Be sure to run postmap against this file to create the hash. Then add check_sender_access hash:/your_file to the smtpd_recipient_restrictions and restart postfix.

Here is a link to some detailed instructions.

You may also see recommendations for performing this action with spamassassin. This can work as you can create a custom black list which will add 100 points to mail from that recipient, causing spamassassin to flag it. The postfix solution is more direct as it will return an error code at the SMTP level. Undoubtedly you want to avoid 'bouncing' the mail which would undoubtedly be futile, but they may get the message (no pun intended) if your smtp returns a hard error code.

One thing I recall that postfix does by default and you may want to look into this is that it will let them complete a decent portion of the mail transaction and then issue the reject error. I read about this is postfix the definitive guide. I think the reason was to prevent them from knowing what you were filtering on to help prevent them from working around it.

One other thing, you may also be able to implement restrictions in the ehlo portion of the transaction. Just something else to look into.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Command for clearing unwanted email from Qmail. Samael Linux - Server 2 10-30-2009 07:33 AM
how to block unwanted websites in redhat squid proxy gautamnarayan Linux - Server 1 02-26-2009 11:41 AM
does suse 10.0 use a hosts file to block unwanted web sites like windows? sirius57 Linux - Newbie 7 10-30-2008 10:26 PM
Filter unwanted Email tomdlam Linux - Security 1 11-10-2001 11:59 AM

All times are GMT -5. The time now is 06:51 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration