3

i have a problem with my 2 postfix instances. 2 separate IP's and coressponding domain names are setup on networking, they are working fine. I want second mail message (below) to have
Received: from firstInstanceDomain.com (firstInstanceDomain.com. [second.domain.ip])
instead of
Received: from secondInstanceDomain.com (secondInstanceDomain.com. [second.domain.ip])
Othe important information:
-i have DKIM working on both domains
- when i put relayhost = firstInstanceDomain.com in firstInstanceDomain MAIN.CF i have secondInstanceDomain inside mail message from firstInstanceDomain, and secondInstanceDomain mail message is ok
- mail headers from both domains, master and main configs are attached below
I HAVE SPENT 60 HOURS trying to solve it, searching all google resource, postfix documenation, blogs and forums. no luck. Please Help!

MAIL SENT FROM mail@firstInstanceDomain.com

Delivered-To: someMail@domain.com
Received: by 10.68.49.10 with SMTP id q10cs774841pbn;
        Fri, 6 Jan 2012 08:18:06 -0800 (PST)
Received: by 10.213.3.136 with SMTP id 8mr1420319ebn.0.1325866683057;
        Fri, 06 Jan 2012 08:18:03 -0800 (PST)
Return-Path: <mail@firstInstanceDomain.com>
Received: from firstInstanceDomain.com (firstInstanceDomain.com. [first.domain.ip])
        by mx.google.com with ESMTP id 57si5431812eey.212.2012.01.06.08.18.01;
        Fri, 06 Jan 2012 08:18:02 -0800 (PST)
Received-SPF: pass (google.com: domain of mail@firstInstanceDomain.com designates first.domain.ip as permitted sender) client-ip=first.domain.ip;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of mail@firstInstanceDomain.com designates first.domain.ip as permitted sender) smtp.mail=mail@firstInstanceDomain.com; dkim=pass header.i=@firstInstanceDomain.com
To: "someMail@domain.com" <someMail@domain.com>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=firstInstanceDomain.com;
    s=default; t=1325870581;
    RestOfTheKey
Subject: SomeSubject
From: "firstInstanceDomain.com" <mail@firstInstanceDomain.com>
Message-ID: <someId@firstInstanceDomain.com>
Return-To: mail@firstInstanceDomain.com
Date: Fri, 06 Jan 2012 17:23:01 +0000
Content-Type: multipart/alternative;
    boundary="=_1.e091838bd31325ae4da677be1af4efd5"
MIME-Version: 1.0
RestOfTheMessage

MAIL SENT FROM mail@secondInstanceDomain.com

Delivered-To: someMail@domain.com
Received: by 10.68.49.10 with SMTP id q10cs774832pbn;
        Fri, 6 Jan 2012 08:18:01 -0800 (PST)
Received: by 10.213.108.146 with SMTP id f18mr1347667ebp.36.1325866679721;
        Fri, 06 Jan 2012 08:17:59 -0800 (PST)
Return-Path: <mail@secondInstanceDomain.com>
Received: from firstInstanceDomain.com (firstInstanceDomain.com. [first.domain.ip])
        by mx.google.com with ESMTP id 3si24805496eeh.44.2012.01.06.08.17.58;
        Fri, 06 Jan 2012 08:17:59 -0800 (PST)
Received-SPF: softfail (google.com: domain of transitioning mail@secondInstanceDomain.com does not designate first.domain.ip as permitted sender) client-ip=first.domain.ip;
Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning mail@secondInstanceDomain.com does not designate first.domain.ip as permitted sender) smtp.mail=mail@secondInstanceDomain.com; dkim=pass header.i=@secondInstanceDomain.com
To: "someMail@domain.com" <someMail@domain.com>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=secondInstanceDomain.com;
    s=dbdef; t=1325870578;
    RestOfTheKey
Subject: SomeSubject
From: "secondInstanceDomain.com" <mail@secondInstanceDomain.com>
Message-ID: <someId@secondInstanceDomain.com>
Return-To: mail@secondInstanceDomain.com
Date: Fri, 06 Jan 2012 17:22:58 +0000
Content-Type: multipart/alternative;
    boundary="=_1.7183ef0339b880f9a93c3d822619afee"
MIME-Version: 1.0
RestOfTheMessage

MASTER.CF FOR firstInstanceDomain (rest of config is standard)

first.domain.ip:smtp      inet  n       -       n       -       -       smtpd -o myhostname=firstInstanceDomain.com -o mydomain=firstInstanceDomain.com

MASTER.CF FOR secondInstanceDomain (rest of config is standard)

second.domain.ip:smtp      inet  n       -       n       -       -       smtpd -o myhostname=secondInstanceDomain.com -o mydomain=secondInstanceDomain.com

MAIN.CF FOR firstInstanceDomain

smtp_bind_address = first.domain.ip
mydomain=firstInstanceDomain.com
mynetworks=firstInstanceDomain.com
alternate_config_directories = /etc/postfix-third
data_directory = /var/lib/postfix
header_checks = regexp:/etc/postfix/header_checks
inet_interfaces = localhost
mydestination = $mydomain, localhost.$mydomain, $mydomain
myhostname = $mydomain
myorigin=$mydomain
queue_directory = /var/spool/postfix
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
debugger_command =
     PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
     xxgdb $daemon_directory/$process_name $process_id & sleep 5
default_process_limit = 300
html_directory = no
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 10240000
newaliases_path = /usr/bin/newaliases.postfix
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
sample_directory = /usr/share/doc/postfix-2.3.3/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_client_restrictions=
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_sasl_local_domain = 
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_authenticated_header = yes
smtpd_tls_auth_only = no
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 4
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
mailbox_size_limit = 512000000
virtual_alias_maps =hash:/etc/postfix/virtual
smtpd_milters = inet:127.0.0.1:20209
non_smtpd_milters = inet:127.0.0.1:20209
milter_protocol = 2
milter_default_action = accept

MAIN.CF FOR secondInstanceDomain

smtp_bind_address = second.domain.ip
mydomain=secondInstanceDomain.com
mynetworks=secondInstanceDomain.com
alternate_config_directories = /etc/postfix
data_directory = /var/lib/postfix-third
header_checks = regexp:/etc/postfix-third/header_checks
inet_interfaces = localhost
mydestination = $mydomain, localhost.$mydomain, $mydomain
myhostname = $mydomain
myorigin=$mydomain
queue_directory = /var/spool/postfix-third
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
debugger_command =
     PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
     xxgdb $daemon_directory/$process_name $process_id & sleep 5
default_process_limit = 300
html_directory = no
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 10240000
newaliases_path = /usr/bin/newaliases.postfix
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
sample_directory = /usr/share/doc/postfix-2.3.3/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_client_restrictions=
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_authenticated_header = yes
smtpd_tls_auth_only = no
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 4
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
mailbox_size_limit = 512000000
smtpd_milters = inet:127.0.0.1:20209
non_smtpd_milters = inet:127.0.0.1:20209
milter_protocol = 2
milter_default_action = accept
user9517
  • 115,471
  • 20
  • 215
  • 297
lew
  • 33
  • 2

1 Answers1

2

You didn't specify how the mails are created (before sending). As they don't have revealing Received headers I assume that they are created directly on the server. And there is the problem. They are not "created" by sending them via SMTP to the server from a client. And so the configuration in master.cf is ignored completely.

So if you "drop" the mail to a Postfix instance via sendmail or maildrop (or similar) you have to specify to which instance the mail should be "queued" for outbound delivery. Otherwise the first one is assumed.

mailq
  • 17,023
  • 2
  • 37
  • 69
  • 1
    Thank You very much for Your answer. It pointed me in the right direction. I am sending email with advanced email class but at the end it goes to php function mail(). When i set sendmail_path = /usr/sbin/sendmail -t -i -C /etc/postfix-third in httpd.conf everything worked perfectly as planned! Thx again! – lew Jan 07 '12 at 01:20
  • After sending some emails from second instance, I noticed, that every mail, that bounced back from destination host, lands in first postfix instance and can't be send again, because of my spf setup. how can i make postfix pickup mail with correct instance distinguished by ip? smtp_bind_adress does not work . Plese help! – lew Jan 10 '12 at 01:59