0

I run my own mail server, which (among other things) handles emails for one of my services. The service in question takes bookings and sends booking confirmation emails. The emails come from noreply@mydomain.com with a Reply To header set to the email address for the organizer.

Some email clients seem not to honor the Reply To header, and so I get emails sent to the noreply@mydomain.com email.

I have setup postfix to catch these and run a script that looks up the event in question and replies to the email detailing the correct email address for the event, and this all works fine.

The problem is that I also get a lot of spam sent to that email address, so I would rather the reply was a bounce (rather than a new email) to discourage spam, but I'm not sure how to achieve this (or if it's even possible).

What makes a bounce email a bounce email? Does it have to be generated from the sending email server in response to an SMTP error? If so, how do I make it bounce and customize the bounce message (I'm using postfix and this method to run the script). If not, can I modify the email I send in the script to be a bounce email? How do I do this? Is it specific headers in the email?

Ben Holness
  • 944
  • 2
  • 10
  • 28

2 Answers2

1

A receiving MTA should never bounce. SMTP connection-stage rejection is the only way to avoid sending backscatter. Your script would soon become a tool for sending spam.

You can customize the human readable error message. Every sending MTA getting the error from yours will create a bounce with their usual template, but the error message is always somewhere.

A customer should have had bounces before and realize there was something wrong with the recipient address. At least some of them care to try and find your error message, or ask someone who can... read them English.

Example configuration for a custom error message in Postfix:

  • Postfix main.cf:

    smtpd_recipient_restrictions =
        . . .
        check_recipient_access hash:/etc/postfix/denied_recipients,
        . . .
    
  • /etc/postfix/denied_recipients:

    noreply@example.com REJECT This address does not accept email. See https://example.com/contact
    
  • postmap /etc/postfix/denied_recipients, because it's a hash: Berkeley DB.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
  • The thing is that I still want to use a script so that I can get the details of the event (including the correct email address) to include in the bounce message (if that's possible), hence wondering if I can do this from a script. – Ben Holness May 29 '19 at 16:39
  • My ideal situation would be to have the script cause postfix to REJECT the message and provide it with the custom message, but that's the part that I'm not sure whether it's possible or not. – Ben Holness May 29 '19 at 20:51
  • 1
    That would require building a custom [milter](http://www.postfix.org/MILTER_README.html) application. It's more than just a script, because it needs to use the Sendmail 8 Milter protocol, but it's possible. – Esa Jokinen May 30 '19 at 04:35
  • Thanks Esa - I will read up on it! – Ben Holness May 30 '19 at 05:34
  • For anyone looking this up later, I found https://github.com/mschout/milter-limit which is a perl based milter limiting script using Sendmail::PMilter and looks like a good place to help figure out how to build what I want! – Ben Holness May 30 '19 at 17:11
  • Esa Jokinen - If you make your comment an answer, I will accept it - it is the correct answer to my question! :) – Ben Holness May 30 '19 at 17:18
-1

The entire point of a "noreply@somedomain.tld" address is that it doesn't go anywhere.

Put the address to which you want people to reply in the body of the mail, and remove the noreply mailbox from your server(s). In this way everybody sending to the noreply address gets their mail bounced - including spammers - but all literate and legitimate users will know how to get a mail through to the correct address.

Mikael H
  • 5,031
  • 2
  • 9
  • 18
  • I do not have control over the body of the mail, it is customized by the event organizer. Besides which, even if it was there, some people would still reply and I want to provide a good customer service by looking for legitimate accidental replies to the noreply address and dealing with them nicely, if I can. I do not mind putting in the work to do so. – Ben Holness May 29 '19 at 16:26