1

Topic: substitute smtp-mail (FROM)

==== Required information ==== -
iRedMail version:  -  iRedMail-0.8.7
Store mail accounts in which backend (LDAP/MySQL/PGSQL):  - LDAP
Linux/BSD distribution name and version:  - DEBIAN 7
Related log if you're reporting an issue:
====

Hi!
I did a rotation of IP-addresses like this, as described herein:
http://marinovl.blogspot.ru/2012/09/pos … mails.html
http://www.kutukupret.com/2010/12/06/po … -and-perl/

Here master.cf
127.0.0.1:2527 inet n n n - 0 spawn
user = nobody argv = / etc / postfix / random.pl

rotate1 unix - n - smtp
-o syslog_name = postfix-rotate1
-o smtp_helo_name = my-office1.com
-o smtp_bind_address = 46.30.43.8

rotate2 unix - n - smtp
-o syslog_name = postfix-rotate2
-o smtp_helo_name = mail1.my-office1.com
-o smtp_bind_address = 46.30.41.13

rotate3 unix - n - smtp
-o syslog_name = postfix-rotate3
-o smtp_helo_name = mail2.my-office1.com
-o smtp_bind_address = 46.30.42.229

rotate4 unix - n - smtp
-o syslog_name = postfix-rotate4
-o smtp_helo_name = mail3.my-office1.com
-o smtp_bind_address = 46.30.42.230


Here main.cf
transport_maps = proxy: ldap hmm etc / postfix / ldap / transport_maps_user.cf, proxy: ldap hmm etc / postfix / ldap / transport_maps_domain.cf, transport_maps = tcp: [127.0.0.1]: 2527
127.0.0.1:2527 _time_limit = 3600s

Now, what is the problem. The fact that each letter contains the address in the headers smtp-mail (FROM) and the program sends a stream of letters and all the same address smtp-mail (FROM). And any email provider, Yahoo or Google determines this is the address of the smtp-mail (FROM) and, accordingly, it prescribes DKIM signature box containing d = my-office1.com. How do I address to smtp-mail (FROM) when rotation is replaced with the address of the subdomain, from which there is currently shipping. Eg. If the current is sent to a subdomain mail2.my-office1.com, it is necessary to replace the address na@mail2.my-office1.com
Do I have to write a separate script here, or you can do setting postfix?
If this work is worth the money, I will pay

2

Re: substitute smtp-mail (FROM)

rafaello wrote:

Here main.cf
transport_maps = proxy: ldap hmm etc / postfix / ldap / transport_maps_user.cf, proxy: ldap hmm etc / postfix / ldap / transport_maps_domain.cf, transport_maps = tcp: [127.0.0.1]: 2527

Two "transport_maps =" in one line? is it a typo/copy error or it's the real setting in Postfix?

rafaello wrote:

The fact that each letter contains the address in the headers smtp-mail (FROM) and the program sends a stream of letters and all the same address smtp-mail (FROM).

Excuse me, i don't understand what the problem is. What "letter"? What "stream of letters" does the program send? Show us examples please, the more details you gave, the easier for others to help.

rafaello wrote:

And any email provider, Yahoo or Google determines this is the address of the smtp-mail (FROM) and, accordingly, it prescribes DKIM signature box containing d = my-office1.com. How do I address to smtp-mail (FROM) when rotation is replaced with the address of the subdomain, from which there is currently shipping. Eg. If the current is sent to a subdomain mail2.my-office1.com, it is necessary to replace the address na@mail2.my-office1.com
Do I have to write a separate script here, or you can do setting postfix?

Using one DKIM to sign multiple mail domains is normal, no need to replace address in DKIM signature.

3

Re: substitute smtp-mail (FROM)

rafaello wrote: Here main.cf transport_maps = proxy: ldap hmm etc / postfix / ldap / transport_maps_user.cf, proxy: ldap hmm etc / postfix / ldap / transport_maps_domain.cf, transport_maps = tcp: [127.0.0.1]: 2527

 
Oh, yes, of course it's a typo. That must be right: 

transport_maps = proxy: ldap hmm etc / postfix / ldap / transport_maps_user.cf, proxy: ldap hmm etc / postfix / ldap / transport_maps_domain.cf, tcp: [127.0.0.1]: 2527


  I use as a program for sending messages INTERSPIRE EMAIL MARKETER. So, as the address mail (FROM), the program uses the address to bounce Return-Path. When it is sending messages, then all the letters the same Return-Path. But when the flow passes through letters POSTFIX, rotation occurs and letters sent from different IP and different subdomains. Now here are a few examples. Suppose at some point in a letter passed through rotate1. It corresponds to the domain my-office1.com and IP address 46.30.43.8 (see sample in the previous report). That quote headers delivered to the GMAIL: 
Delivered-To: drafaello65@gmail.com
Received: by 10.114.190.197 with SMTP id gs5csp638571ldc;
        Wed, 9 Jul 2014 10:41:15 -0700 (PDT)
X-Received: by 10.194.48.103 with SMTP id k7mr49071697wjn.68.1404927675036; 
       Wed, 09 Jul 2014 10:41:15 -0700 (PDT)
Return-Path: <raf19652008@my-office1.com>
Received: from my-office1.com (my-office1.com. [46.30.43.8])
         by mx.google.com with ESMTPS id bo7si8993553wib.66.2014.07.09.10.41.14
         for <drafaello65@gmail.com>
         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
         Wed, 09 Jul 2014 10:41:14 -0700 (PDT)
Received-SPF: pass (google.com: domain of raf19652008@my-office1.com designates 46.30.43.8 as permitted sender) client-ip=46.30.43.8;
Authentication-Results: mx.google.com;
        spf=pass (google.com: domain of raf19652008@my-office1.com designates 46.30.43.8 as permitted sender)
       smtp.mail=raf19652008@my-office1.com;
        dkim=pass header.i=@my-office1.com;
Received: from localhost (localhost [127.0.0.1])
     by mx.my-office1.com (Postfix) with ESMTP id 780E5160074
     for <drafaello65@gmail.com>; Wed,  9 Jul 2014 21:41:14 +0400 (MSK)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=my-office1.com; h=
     content-transfer-encoding:content-type:content-type
     :list-unsubscribe:mime-version:reply-to:from:from:date:date
     :message-id:subject:subject:to; s=dkim; t=1404927670; x=
     1405791671; bh=NVzyQDJtKrYl2cP6heTzOl8U2jQfiUsMRZtmM7pYg4M=; b=D     HoyhSXR9Pr14p9Pdl9T46PakgVpZBCH47OIgZeOumXtklSlwNQgRRytCQF5XR2gq     knN6yKSxOWzKXinYCvmA7jN8gmBOmg7Ycy4Y5qH8wg1Bpq6pyzDpo9XJfNJtOYvq     hupGfpVqdNg/sJQjqziA3jwCNU7PyzAlpMeJOkoG+U=

Please note that the Return-Path: (@ my-office1.com) corresponds smtp.mail = (@ my-office1.com)
Also, note that dkim = pass header.i = @ my-office1.com and d = my-office1.com

Now, suppose that the letter passed through rotate3. It corresponds to the subdomain mail2.my-office1.com and IP address 46.30.42.229
That quote headers delivered to the GMAIL:

Delivered-To: drafaello65@gmail.com
Received: by 10.114.190.197 with SMTP id gs5csp637909ldc;
        Wed, 9 Jul 2014 10:28:17 -0700 (PDT)
X-Received: by 10.180.8.10 with SMTP id n10mr13201552wia.41.1404926897376;
        Wed, 09 Jul 2014 10:28:17 -0700 (PDT)
Return-Path: <raf19652008@my-office1.com>
Received: from mail2.my-office1.com (mail2.my-office1.com. [46.30.42.229])
        by mx.google.com with ESMTPS id lr2si59105585wjb.97.2014.07.09.10.28.17
        for <drafaello65@gmail.com>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 09 Jul 2014 10:28:17 -0700 (PDT)
Received-SPF: pass (google.com: domain of raf19652008@my-office1.com designates 46.30.42.229 as permitted sender) client-ip=46.30.42.229;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of raf19652008@my-office1.com designates 46.30.42.229 as permitted sender)
smtp.mail=raf19652008@my-office1.com;
       dkim=pass header.i=@my-office1.com;
Received: from localhost (localhost [127.0.0.1])
    by mx.my-office1.com (Postfix) with ESMTP id DA13A16144E
    for <drafaello65@gmail.com>; Wed,  9 Jul 2014 21:28:13 +0400 (MSK)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=my-office1.com; h=
    content-transfer-encoding:content-type:content-type
    :list-unsubscribe:mime-version:reply-to:from:from:date:date
    :message-id:subject:subject:to; s=dkim; t=1404926889; x=
    1405790890; bh=6yU07ggljK7h/0bjz4ZzlsvXtTggsQ5DdPQawxP5Yoc=; b=s
    2loYtj0OFrnkWs+xZhidkdAfqpRTL2NOrFD5VpxFNVRbdorhU0NiEVL0FZuxtKaa
    lzf4FXOcb61728m5TiBLDr3TrBiWp47bfiYsUYQC1SN7Vzord62JCQZA7SlQZ3Rr
    ekXqfqW+h6kk0UM9QADNk6MRWTQK6kHOeoL9qUI47w=

Note that GMAIL ignored here this line:

Received: from mail2.my-office1.com (mail2.my-office1.com. [46.30.42.229])

and pointed smtp.mail =, header.i = d = and all the same domain (@ my-office1.com), although made with shipping subdomen @mail2.my-office1.com
Thereby, I want to say that crucial address Return-Path:. On the basis of a field determines GMAIL
smtp.mail =, header.i = and d =

And now an example of how it should be correct.
Suppose that the letter passed through rotate2. It corresponds to the subdomain mail1.my-office1.com and IP address 46.30.42.229
Also, I deliberately altered Return-Path program INTERSPIRE EMAIL MARKETER. I instead of @my-office1.com has registered @mail1.my-office1.com
That quote headers delivered to the GMAIL:

Delivered-To: drafaello65@gmail.com
Received: by 10.114.190.197 with SMTP id gs5csp639854ldc;
        Wed, 9 Jul 2014 11:06:14 -0700 (PDT)
X-Received: by 10.180.10.168 with SMTP id j8mr13413829wib.73.1404929174582;
        Wed, 09 Jul 2014 11:06:14 -0700 (PDT)
Return-Path: <raf19652008@mail1.my-office1.com>
Received: from mail1.my-office1.com (mail1.my-office1.com. [46.30.41.13])
        by mx.google.com with ESMTPS id xn13si9106308wib.13.2014.07.09.11.06.14
        for <drafaello65@gmail.com>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 09 Jul 2014 11:06:14 -0700 (PDT)
Received-SPF: pass (google.com: domain of raf19652008@mail1.my-office1.com designates 46.30.41.13 as permitted sender) client-ip=46.30.41.13;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of raf19652008@mail1.my-office1.com designates 46.30.41.13 as permitted sender) smtp.mail=raf19652008@mail1.my-office1.com;
       dkim=pass header.i=@mail1.my-office1.com;
Received: from localhost (localhost [127.0.0.1])
    by mx.my-office1.com (Postfix) with ESMTP id AA4A91601F6
    for <drafaello65@gmail.com>; Wed,  9 Jul 2014 22:06:13 +0400 (MSK)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail1.my-office1.com;
     h=content-transfer-encoding:content-type:content-type
    :list-unsubscribe:mime-version:reply-to:from:from:date:date
    :message-id:subject:subject:to; s=dkim; t=1404929169; x=
    1407521170; bh=ffHl+nBvM81rFL/1H8N4bk0W/YvHtVYKDIiIGomlW2Y=; b=U
    sNLUrNgNkAU7StR7tOLEMRz1ftc5Ry5Ihl0jnHfTV9Bh1LNhowbj3Do5eBhKq6aQ
    FMa1AxugL3wtOnICtok5oEyGmJk1TBJ1ON2h7lVp14ICPwqMIb4ZHWqkWkhirpmQ
    LU5wDPSeXpXRE4/O32wpuxuHoJqrlVO1mghzdoelAo=

As you can see, address Return-Path: is crucial for defining such fields as smtp.mail =, header.i = and d =

I want to say that the meaning of this topic to field smtp.mail =, header.i = d = and each time corresponded to that domain / subdomain, with which at the moment is sending a message. Therefore, the only way - is to replace the mail (FROM) or Return-Path to the address from which you are shipping at the moment.
For example, if it is sent to the subdomain mail2.oni4you.ru, then mail (FROM) or Return-Path must be @mail2.my-office1.com, and if shipping comes with mail1.oni4you.ru, then mail (FROM) or Return-Path must be @mail1.my-office1.com

4

Re: substitute smtp-mail (FROM)

I'm so sorry that i don't fully understand your situation, but i guess you need option 'canonical_maps=' in your addition transports to rewrite sender address. For example:

rotate1 unix - n - smtp
    -o syslog_name = postfix-rotate1
    -o smtp_helo_name = my-office1.com
    -o smtp_bind_address = 46.30.43.8
    -o canonical_maps=hash:/etc/postfix/canonical_maps.cf

Reference: http://www.postfix.org/postconf.5.html#canonical_maps

I don't see there's need to modify DKIM in your case.

5

Re: substitute smtp-mail (FROM)

Oh, yes, of course!
No need to change DKIM, you only need to change the address of the sender!
DKIM change itself in the headlines of incoming letters, depending on the domain address of the sender.
Now, perhaps, you should write a regular expression to map canonical_maps.
You can help write these regular expressions?
I'll buy a ticket support as automatical solution!
Thank you!

6

Re: substitute smtp-mail (FROM)

According to Postfix document, there's no regular expression required.
http://www.postfix.org/canonical.5.html

Sample:

@my-office1.com @mail1.my-office1.com

Don't forget to execute below command after modified this file:

# postmap hash:/etc/postfix/canonical_maps

7

Re: substitute smtp-mail (FROM)

Dear ZhangHuangbin!
For three days I tried to use your advice, but it does not work, then why.
Tried this:

rotate1 unix - n - smtp
   -o syslog_name = postfix-rotate1
   -o smtp_helo_name = my-office1.com
   -o smtp_bind_address = 46.30.43.8
rotate2 unix - n - smtp
   -o syslog_name = postfix-rotate2
   -o smtp_helo_name = mail1.my-office1.com
   -o smtp_bind_address = 46.30.41.13
   -o canonical_maps = hash hmm etc/postfix/canonical_maps1.cf
rotate3 unix - n - smtp
   -o syslog_name = postfix-rotate3
   -o smtp_helo_name = mail2.my-office1.com
   -o smtp_bind_address = 46.30.42.229
   -o canonical_maps = hash hmm etc/postfix/canonical_maps2.cf
rotate4 unix - n - smtp
   -o syslog_name = postfix-rotate4
   -o smtp_helo_name = mail3.my-office1.com
   -o smtp_bind_address = 46.30.42.230
   -o canonical_maps = hash hmm etc/postfix/canonical_maps3.cf

Verification shows that postfix sees cards:
# Postmap-q @ my-office1.com hash hmm etc/postfix/canonical_maps1
@ mail1.my-office1.com
# Postmap-q @ my-office1.com hash hmm etc/postfix/canonical_maps2
@ mail2.my-office1.com
# Postmap-q @ my-office1.com hash hmm etc/postfix/canonical_maps3
@ mail3.my-office1.com

But the address is not replaced!! When sending messages, the rotation occurs, but the address will not be replaced!
Then he tried to replace
canonical_maps on sender_canonical_maps
and
canonical_maps on smtp_generic_maps

Still does not address are replaced!
Please give advice!
My offer still stands, if it is necessary, I will pay for a paid ticket.

8

Re: substitute smtp-mail (FROM)

if it doesn't work, i'm afraid that you have to try multiple Postfix instances instead.

9 (edited by rafaello 2014-07-23 11:32:53)

Re: substitute smtp-mail (FROM)

Hello, dear ZhangHuangbin! 
I spoke with your question on the official site postfix.org and received from them an answer here: 

With postfix-2.12-201407xx, use:   
/etc/postfix/main.cf:     
transport_maps = randmap:!smtp1!smtp2!smtp3 (and so on)   
where smtp1, smtp2, etc. are defined in master.cf. 
http://mirror.optimising.com.au/postfix … EASE_NOTES

   
In this connection, I tried to update the existing version of postfix (2.9.6-2) to version 2.12-201407.
But unfortunately, the team
apt-get update
apt-get upgrade
postfix does not update to the correct version?
Can it be done manually as it is? How can this be done?
Thank you!

10

Re: substitute smtp-mail (FROM)

rafaello wrote:

postfix does not update to the correct version?

Obviously, Debian 7 stable branch won't provide snapshot version of Postfix.

rafaello wrote:

Can it be done manually as it is? How can this be done?

You can download the Postfix source tarball, compile and install it.

But let's back to your original issue, does it solve the address rewritten issue (canonical_maps?)?

11

Re: substitute smtp-mail (FROM)

Dear ZhangHuangbin!
Do you agree to help and install it on my server multiple Postfix instances?
If so, tell me where to send you a small technical task.
Upon approval of the assignment, you can assign the cost of doing this work.
Thank you!