8

I would like to reject mails to a certain address with a custom message. Mails to other non existing addresses should be unchanged. How can I do that? I'm using Postfix 2.7.0 on Ubuntu 10.4.

Background: My websites sends mails to my users, and so far, my personal address is used as the sender. I would like to change this to a noreply@... address, but since the users reply quite often to these emails, I would like to send them a helpful reject message.

Thanks!

  • So, basically you want to reply with a helpful reject message on messages sent to a noreply address :) – ΤΖΩΤΖΙΟΥ May 8 '11 at 15:54
  • I recommend using a customer service email address if possible, rather than a noreply@ email address. That way the users can reply and get a response. :) – Collin Anderson Sep 9 '16 at 19:51
17

Create a custom_replies map (i.e. /etc/postfix/custom_replies) with the following contents:

noreply@mydomain.com REJECT Like I said, NOREPLY

Run sudo postmap /etc/postfix/custom_replies.

Edit /etc/postfix/main.cf and put the following as the first check of the smtpd_recipient_restrictions:

check_recipient_access hash:/etc/postfix/custom_replies,

Then issue a sudo postfix reload.

Try sending email to noreply@mydomain.com:

$ telnet localhost 25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mydomain.com ESMTP Postfix (Ubuntu)
HELO localhost
250 mydomain.com
MAIL FROM: <god@mydomain.com>
250 2.1.0 Ok
RCPT TO: <noreply@mydomain.com>
554 5.7.1 <noreply@mydomain.com>: Recipient address rejected: Like I said, NOREPLY
quit
221 2.0.0 Bye
| improve this answer | |
  • Obviously I ran the telnet session on the mail server itself. – ΤΖΩΤΖΙΟΥ May 8 '11 at 16:37
  • I recommend using PCRE (and not HASH) so you do need to run "postmap" every time the file is modified. It's just one less hassle. – Brian Smith Jun 2 '17 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.