Score:3

Configuring Postfix to Use Duplicate Services with Different Options

br flag

I'm attempting to create two distinct configurations for sending outbound emails in Postfix, utilizing two binding IPs (primary=11.11.11.11 and secondary=22.22.22.22) 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 = 11.11.11.11
  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=22.22.22.22

After restarting Postfix, I received this error:

Mar 23 09:02:23 test1 postfix/master[93837]: fatal: 127.0.0.1:smtp2: 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: [email protected], 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.

Score:2
fr flag
anx

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=192.0.2.22
 -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.

Mquinteiro avatar
br flag
Do you have to use transport map or sender_dependent_default_transport_maps? I did with sender_dependant and works perfectly.
anx avatar
fr flag
anx
@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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.