I'm attempting to create two distinct configurations for sending outbound emails in Postfix, utilizing two binding IPs (primary= and secondary= for smtpd. However, I'm encountering issues with my current setup. Here's what I've tried so far:

  1. Added the following line to main.cf:
    sender_dependent_default_transport_maps = hash:/etc/postfix/sender_transport smtp_bind_address =
  1. Created and postmapped /etc/postfix/sender_transport with the content:
    @example.com smtp2
  1. Added a line to master.cf for the second smtp as:
    smtp2 inet n - y - - smtpd
      -o smtp_bind_address=

After restarting Postfix, I received this error:

Mar 23 09:02:23 test1 postfix/master[93837]: fatal: Servname not supported for ai_socktype

When I added the smtp2 service to /etc/services and tried sending from example.com, I encountered these messages:

warning: connect to transport private/smtp2: No such file or directory

Mar 23 09:02:53 test1 postfix/error[93181]: B8B8E3F1B4: to=foo@bar.example, relay=none, delay=564, delays=564/0.02/0/0.01, dsn=4.3.0, status=deferred (mail transport unavailable)

I suspect there might be a conceptual misunderstanding in my approach, but I'm not sure what it is.

1 Answer 1


There is no need to mingle outgoing port and internal reachability. The components to accept messages via smtp (smtpd = daemon) and the components to transmit messages via smtp (sans d = client role) are separate.

When you create a new outgoing SMTP transport, you want to bind it to a unix socket, only accessible to postfix. Such sockets are identified by (file)name, in no way connected to named port reservations in /etc/services.

After reading man 5 master, then man 8postfix smtp and man 5 transport you will likely settle with configuration like this:

# in master.cf:
smtp-identifier unix - - y - 3 smtp
 -o syslog_name=postfix/$service_name
 -o smtp_bind_address=
 -o smtp_bind_address6=2001:db8::d34d:beef

# in any transport map:
#  a name before the colon overrides transport
#  a name without colon would merely override nexthop of unchanged transport
@example.com    smtp-identifier:

The TCP port that service eventually uses to transmit messages will be dynamically allocated.

  • Do you have to use transport map or sender_dependent_default_transport_maps? I did with sender_dependant and works perfectly.
    – Mquinteiro
    Mar 23 at 15:55
  • @Mquinteiro Depends. You chose the one that lets you select on what you want to select on. Only on the right hand side do the different types of transport maps work the same.
    – anx
    Mar 23 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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