Score:1

Cannot assign different IPs for outgoing email using Postfix and Webmin

gd flag

I'm trying to run Mac Mini M1 as a SMTP mail server. I have 5 static IPs, each on its own network interface, with 5 different domains (with the corresponding PTR records).

I have installed Webmin successfully, and I'm trying to configure the mail server using Postfix.

Here are the non-default parameters from my main.cf

biff    no
compatibility_level 2
debugger_command    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory  /usr/share/doc/postfix/html
mail_owner  _postfix
mailbox_size_limit  0
manpage_directory   /usr/share/man
message_size_limit  10485760
mydestination   domain1.org, domain2.com, domain3.net, domain4.net, domain5.org
mynetworks  127.0.0.0/8, [::1]/128
mynetworks_style    subnet
queue_directory /private/var/spool/postfix
readme_directory    /usr/share/doc/postfix
recipient_delimiter +
sample_directory    /usr/share/doc/postfix/examples
sender_dependent_default_transport_maps hash:/etc/postfix/sender_transport
setgid_group    _postdrop
smtpd_client_restrictions   permit_mynetworks permit_sasl_authenticated permit

I've added the 5 domains under mydestination. I successfully receive email for them. As I want every domain name to use its own IP for outgoing email, I've added sender_dependent_default_transport_maps in /etc/postfix/sender_transport which looks like this:

@domain1.org    uniqueid1:
@domain2.org    uniqueid2:
@domain3.net    uniqueid3:
@domain4.com    uniqueid4:
@domain5.net    uniqueid5:

Then in the end of master.cf I've added the following to connect the domains to the IPs:

uniqueid1  unix -       -       n       -       -       smtp
   -o smtp_bind_address=123.123.123.120
   -o smtp_helo_name=domain1.org
   -o syslog_name=postfix-customer-uniqueid1

uniqueid2  unix -       -       n       -       -       smtp
   -o smtp_bind_address=123.123.123.121
   -o smtp_helo_name=domain2.org
   -o syslog_name=postfix-customer-uniqueid2

uniqueid3  unix -       -       n       -       -       smtp
   -o smtp_bind_address=123.123.123.122
   -o smtp_helo_name=domain3.net
   -o syslog_name=postfix-customer-uniqueid3

uniqueid4  unix -       -       n       -       -       smtp
   -o smtp_bind_address=123.123.123.123
   -o smtp_helo_name=domain4.com
   -o syslog_name=postfix-customer-uniqueid4

uniqueid5  unix -       -       n       -       -       smtp
   -o smtp_bind_address=123.123.123.124
   -o smtp_helo_name=domain5.net
   -o syslog_name=postfix-customer-uniqueid5

I've ran postmap hash:/etc/postfix/sender_transport, also I've restarted postfix numerous times.

Every time I try to send an email, it always comes from domain1.org and the first IP corresponding to it 123.123.123.120.

Svetoslav Genov avatar
gd flag
Thank you for your reply. No smtp_bind_address6 in master.cf. I believe this is needed for IPv6, which I do not use? postmap -q [email protected] hash:/etc/postfix/sender_transport command returns no results in the Terminal. I'm not sure where the log created by postfix is located in MacOS.
anx avatar
fr flag
anx
My mistake, you have to query just @domain, so something like `postmap -q @domain2.example hash:/etc/postfix/sender_transport` and that should print `uniqueid2:` if the mapping works.
Svetoslav Genov avatar
gd flag
It successfully prints the uniqueid for all the 5 domains. So mapping seems to be working/correct.
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.