Postfix: Set custom SMTP Banner based on address used to access server

The Postfix parameter smtpd_banner sets the text of a server's SMTP greeting banner. The default setting is:

smtpd_banner = $myhostname ESMTP $mail_name

My mail server has several unique IP addresses assigned to it, one per domain for which it hosts email. In other words, something like this:

  • 203.0.113.1 for example1.com
  • 203.0.113.2 for example2.com
  • 203.0.113.3 for example3.com

A sending server wanting to send email to [email protected] would access the server using example2.com and 203.0.113.2.

I would like the SMTP banner to reflect the domain that is being used to access the mail server. For example, someone accessing the server using example2.com or 203.0.113.2 should see the SMTP Banner:

example2.com ESMTP Postfix

Anyone accessing using the other domains or IP addresses should see the respective domain printed in the place of $myhostname in the default setting.

Is this possible with Postfix, preferably without running multiple instances of Postfix, and if so, how?


The parameter can only be set once, so you will not be able to dynamically change it, however you can override it in Postfix's master.cf file as explained in this SF answer.

The only way (that I know of) is for you to run several Postfix instances as you suggested, however for the sake of a SMTP banner, I personally think this is overkill.