0

I'm new on postfix , until now i worked with exim and i can not do a configuration on postfix that i manage to do it with exim

I have 3 domains and each one have 5 emails addresses

domain1.com with user11@domain1.com, user12@domain1.com ... user15@domain1.com domain2.com with user21@domain2.com, user22@domain2.com ... user25@domain2.com domain3.com with user31@domain3.com, use32@domain3.com ... user35@domain3.com

and for each user I want to specific a unique ip for sending email . he will connect to smtpXX.domainX.com and i want that outgoing email to be from ip of smtpXX.domainX.com and also the mail HELO to be smtpXX.domainX.com,

I try until now in different solutions and last one https://serverfault.com/a/650326/443941 but still no success:

the smtp login is working on port 587

i setup also :

31.xx.xx.xx:submission  inet    n   -   n   -   -   smtpd

i try to connect from home computer that is behind a router, I try to connect to smtp11.domain1.com where ip is 31.xx.xx.189 the received header setup it by my postfix is ok but the receiver server see the hostname of my server (server.hostname.com) and also the main ip of server... below is what i get :

Received: from [31.xx.xx.85] (port=47010 helo=server.hostname.com)
by host.some-server.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
(Exim 4.89)
(envelope-from <test@domain1.com>)
id 1eEJd3-0004bH-0B
for receiver@example.com; Mon, 13 Nov 2017 20:38:41 +0200
Received: from [lo.cal.ip.add] (unknown [some.router.ip.addres])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
by smtp11.domain1.com (Postfix) with ESMTPSA id 0ABB627AXXXX
for <receiver@example.com>; Mon, 13 Nov 2017 20:37:43 +0200 (EET)

someone can help me ? I use Centos 7 , postfix 2.10, virtualmin (also i try on CWP with same results)

UPDATE

main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, server.myhostnamedomain.com, $mydomain
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debugger_command =
     PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
     ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
sender_dependent_default_transport_maps = hash:/etc/postfix/dependent
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtp_tls_security_level = may
mailbox_size_limit = 0
allow_percent_hack = no
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
debug_peer_list = my-domain-1

master.cf

127.0.0.1:smtp      inet    n   -   n   -   -   smtpd
 -o smtpd_sasl_auth_enable=yes
 -o smtp_helo_name=localhost
 -o smtp_bind_address=127.0.0.1
 -o myhostname=localhost
31.xx.xx.85:smtp        inet    n   -   n   -   -   smtpd
 -o smtpd_sasl_auth_enable=yes
 -o smtp_helo_name=smtp1.my-domain-1.com
 -o smtp_bind_address=31.xx.xx.85
 -o myhostname=smtp1.my-domain-1.com
31.xx.xx.189:smtp       inet    n   -   n   -   -   smtpd
 -o smtpd_sasl_auth_enable=yes
 -o smtp_helo_name=smtp12.my-domain-1.com
 -o smtp_bind_address=31.xx.xx.189
 -o myhostname=smtp12.my-domain-1.com
127.0.0.1:submission inet n       -       n       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_reject_unlisted_recipient=no
  -o smtp_helo_name=localhost
  -o smtp_bind_address=127.0.0.1
  -o myhostname=localhost
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
31.xx.xx.85:submission inet n       -       n       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtp_helo_name=smtp1.my-domain-1.com
  -o smtp_bind_address=31.xx.xx.85
  -o myhostname=smtp1.my-domain-1.com
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
31.xx.xx.189:submission inet n       -       n       -       -       smtpd
  -o smtp_helo_name=smtp12.my-domain-1.com
  -o smtp_bind_address=31.xx.xx.189
  -o myhostname=smtp12.my-domain-1.com
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
127.0.0.1:smtps     inet  n       -       n       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtp_helo_name=localhost
  -o smtp_bind_address=127.0.0.1
  -o myhostname=localhost
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
31.xx.xx.85:smtps     inet  n       -       n       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_reject_unlisted_recipient=no
  -o smtp_helo_name=smtp1.my-domain-1.com
  -o smtp_bind_address=31.xx.xx.85
  -o myhostname=smtp1.my-domain-1.com
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
31.xx.xx.189:smtps     inet  n       -       n       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtp_helo_name=smtp12.my-domain-1.com
  -o smtp_bind_address=31.xx.xx.189
  -o myhostname=smtp12.my-domain-1.com
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
pickup    unix  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
relay     unix  -       -       n       -       -       smtp
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache

smtp-151060553215710    unix    -   -   n   -   -   smtp -o smtp_bind_address=31.xx.xx.189

dependent file

@smtp12.my-domain-1.com smtp-151060553215710

email headers

Return-Path: <test@my-domain-1.com>
Delivered-To: receiver@receving-domain.com
Received: from host.host-for-reciving.com
    by host.host-for-reciving.com with LMTP id eCEjEXO1Clq9TQAAIPTFlQ
    for <receiver@receving-domain.com>; Tue, 14 Nov 2017 11:20:51 +0200
Return-path: <test@my-domain-1.com>
Envelope-to: receiver@receving-domain.com
Delivery-date: Tue, 14 Nov 2017 11:20:51 +0200
Received: from [31.xx.xx.85] (port=48868 helo=server.localdomain)
    by host.host-for-reciving.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
    (Exim 4.89)
    (envelope-from <test@my-domain-1.com>)
    id 1eEXOl-0002TT-76
    for receiver@receving-domain.com; Tue, 14 Nov 2017 11:20:51 +0200
Received: from [192.168.10.11] (unknown [external personal ip])
    by smtp12.my-domain-1.com (Postfix) with ESMTPA id D56F32835F1C
    for <receiver@receving-domain.com>; Tue, 14 Nov 2017 09:19:50 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 smtp12.my-domain-1.com D56F32835F1C
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
    d=my-domain-1.com; s=default; t=1510651190;
    bh=VazKNaSjnZAeKOSBMBWmlM99/xJ8HmJ4H2d+B/wNoE8=;
    h=To:From:Subject:Date:From;
    b=uaD3aX+xsVAqKjaqqZrcfG+83gR+nxdHicjxN48IpubMvfbOLR/+i3Mz6Gr2OBFAq
     XRrSrxTe4LyM6V3mcY2sUo3i2f9LXS4Zktka1jsGI+IoduGvzTaa6c8pF0yn8u6N4a
     xupaom0/++cCovIFUG03XCl+A4belApaM0nb7JfpLhkR9Q36BWkePdDLNPYe5/GjYN
     noZTAZzPs9mYD8yc52l7NLpY+vxGr828649Yio8UAwKmzJirORBGKXeFoxvALtSi7z
     klYtu+ZA+2TlekgWZHQvHbseAAH6XF8NQGYX9IE2kQ+fSEFOG6psqz1vzE/IRj/ZiT
     G3oQzy02F/KFw==
To: receiver@receving-domain.com
From: Some Name <test@my-domain-1.com>
Subject: sdadf
Message-ID: <76e4eb13-02e8-d2c5-3fd4-2dc929f6070b@my-domain-1.com>
Date: Tue, 14 Nov 2017 11:19:49 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
 Thunderbird/52.4.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US

sdfasdfasdf

1 Answers1

2

Take a look at Postfix Architecture Overview. In your master.cf you have configured multiple smtpds for receiving mail using different settings (both IPs and protocols). However, Postfix delivers mail using a different component: smtp.

  1. You need to configure additional SMTP clients (outgoing transports) in your master.conf:

    smtp1-out  unix -       -       n       -       -       smtp
       -o smtp_bind_address=31.xx.xx.85
       -o smtp_helo_name=smtp1.example.com
       -o syslog_name=postfix-smtp1
    
    smtp12-out unix -       -       n       -       -       smtp
       -o smtp_bind_address=31.xx.xx.189
       -o smtp_helo_name=smtp12.example.com
       -o syslog_name=postfix-smtp12
    
  2. Then you need to configure sender dependent transport maps in main.cf:

    sender_dependent_default_transport_maps = hash:/etc/postfix/sender_transport
    
  3. In that /etc/postfix/sender_transport you need to map your domains to the transports:

    # Use source IP - 31.xx.xx.85
    @example.com            smtp1-out:
    
    # Use source IP - 31.xx.xx.189
    @example.net            smtp12-out:
    
  4. Since this is a hash: type lookup table, sudo postmap /etc/postfix/sender_transport.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129