Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reject mail? 1

Status
Not open for further replies.

inetd

Technical User
Jan 23, 2002
115
HK
How to reject mail to specific user in postfix?

 
Good question.
Actually, I'm hoping to take this a bit further. I have a list of people (domains) who send me mail that I'd like to automagically bounce back to them, with a suitable message, eg. "Your unsolicited email is unwelcome. All messages from your domain will be rejected."
Haven't yet been able to see whether postfix can do this, or whether it is better done with a procmail 'recipe'.
Any suggestions gratefully received.

ß


 
inetd:
You need to add a
Code:
smtp_recipient_restrictions
lookup table to your main.cf. Example:
Code:
smtp_recipient_restrictions = hash:/etc/postfix/bad-recipient

- in /etc/postfix/bad-recipient -

recipient@ REJECT

Bluegopher:
You have a few options. You can add a
Code:
smtp_sender_restrictions
lookup table. Example:
Code:
smtp_sender_restrictions = hash:/etc/postfix/bad-domains

- in /etc/postfix/bad-domains -

spammer.com 550 Your unsolicited email is unwelcome.  All messages from your domain will be rejected.
You could use a rewrite so all messages from certain domains go to a single e-mail box and then procmail sends back a return message. The only problem with trying to send a response is that most from headers point to non-existant mailboxes. The first solution will make it so that the mail in never accepted on your side.

Hope that helps.
 
Hi usige (TechnicalUser)

Thx for those clues. I give you a star.
This is also quite well described in /etc/postfix/access that comes with postfix.
But, its not quite working for me.
Actually, the incoming offending email is correctly discarded (I checked the maillog), but its not bouncing back to the sender. Could this be becuase I have an "off-line" postfix server. My mail server uses fetchmail to collect email from a small number of ISP's. Fetchmail then delivers the email to postfix, for processing and placement in mailboxes for local users. Postfix handles email for local LAN, and uses relayhost=mail.myisp.com command to deliver outgoing emails. Hope this makes sense.
Is there any way I can make the bounce/reject work. Maybe I need to try procmail after all, but I'd rather stick with postfix if I can.

More thx.

 
Glad that helped. It's nice knowing all this stuff rattling around in my head can be of use (-:

It's been many years since I ran an off-line mailer, but I suspect that my be the problem.

If you were directly connected when "mail.spammer.com" connected it would receive a 550 error and the sending MTA should send a bounce message back to the sender. Since fetchmail injects the mail into postfix, fetchmail would be the one that receives the 550 message. I think you might be able to set the fetchmail parm
Code:
spambounce
and that will send a bounce message through your local postfix. I've never tried it so let me know if it works.

Hopefully that give some more clues and ideas.
 
Yo the man. That almost works, and will be perfect when I fix up the hostname, domain name issues presently causing the bounced mail to be rejected by my ISP. At least I can see that the access.db is working, postfix rejects email being received from fetchmail, fetchmail recognizes the bounce and gives it back to postfix for delivery via nominated relayhost. Aint the maillog wonderful.
Thx again.
ß

 
Glad that it seems to work. I will have to keep this in mind if I need to bounce spam for off-line servers.

Thanks for being a guineapig (or gopher as the case may be) for my ideas. Anytime you want to test out my ideas for me fell free to volunteer ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top