Split multiple recipient mail

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Split multiple recipient mail

Thomas Spycher
Hi,

if Postfix receives an mail with multiple recipients (eg. to, cc and bcc). This mail gets processes as one single mail by postfix. How could it get accomplished to change the content of the mail for each recipient in an different way?
Currently i've done this in an content filter. The Content filter gets the mail and does its stuff for each recipient and then requeues it again for each recipient.

I would like to know, if there is an different way? An more postfix-like way?

Greetings from Switzerland
Tom

Reply | Threaded
Open this post in threaded view
|

Re: Split multiple recipient mail

Jeroen Geilman
On 07/09/2012 05:47 PM, Thomas Spycher wrote:
> Hi,
>
> if Postfix receives an mail with multiple recipients (eg. to, cc and bcc). This mail gets processes as one single mail by postfix.

Only on reception; when it is queued, the message is duplicated as many
times as necessary to address all next-hop destinations.

>   How could it get accomplished to change the content of the mail for each recipient in an different way?

The MTA is really the wrong place to manipulate message content - but
it's ultimately up to you.

> Currently i've done this in an content filter. The Content filter gets the mail and does its stuff for each recipient and then requeues it again for each recipient.

Sounds like you've solved it, then.

> I would like to know, if there is an different way? An more postfix-like way?

Since you're *changing the message for each recipient*, they must be
split up into separate messages.
It doesn't really matter how you do that.

I would probably opt to make it a fully controllable process by first
queueing and re-injecting it into a second listener or postfix instance
by utilizing ${second-smtpd}_recipient_limit = 1

This forces all multi-recipient mail to be split up before it reaches
your content filter, thus simplifying the overall design.

--
J.

Reply | Threaded
Open this post in threaded view
|

Re: Split multiple recipient mail

Viktor Dukhovni
On Tue, Jul 10, 2012 at 12:45:34AM +0200, Jeroen Geilman wrote:

> I would probably opt to make it a fully controllable process by
> first queueing and re-injecting it into a second listener or postfix
> instance by utilizing ${second-smtpd}_recipient_limit = 1

Right idea, wrong implementation. A better solution is to set the

        <transport>_destination_recipient = 1

where <transport> is the name of the dedicated transport used to
feed messages into the content_filter. For example:

        main.cf:
                content_filter = cf_smtp
                cf_smtp_destination_recipient_limit = 1

        master.cf:
                cf_smtp unix ... smtp

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Split multiple recipient mail

Thomas Spycher
Uhhh, this is a much more better Solution than getting this done by the content filter.
I've set smtp_destination_recipient_limit = 1 so every mail gets passed to the content filter for each recipient and finally gets requeued as a complete new mail. Perfect!

Thank you!

On Jul 10, 2012, at 02:44 , Viktor Dukhovni wrote:

> On Tue, Jul 10, 2012 at 12:45:34AM +0200, Jeroen Geilman wrote:
>
>> I would probably opt to make it a fully controllable process by
>> first queueing and re-injecting it into a second listener or postfix
>> instance by utilizing ${second-smtpd}_recipient_limit = 1
>
> Right idea, wrong implementation. A better solution is to set the
>
> <transport>_destination_recipient = 1
>
> where <transport> is the name of the dedicated transport used to
> feed messages into the content_filter. For example:
>
> main.cf:
> content_filter = cf_smtp
> cf_smtp_destination_recipient_limit = 1
>
> master.cf:
> cf_smtp unix ... smtp
>
> --
> Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: Split multiple recipient mail

Viktor Dukhovni
On Tue, Jul 10, 2012 at 10:06:54AM +0200, Thomas Spycher wrote:

> Uhhh, this is a much more [sic] better Solution than getting this done
> by the content filter.  I've set smtp_destination_recipient_limit = 1

I did point out that this should be a "dedicated" transport used
only for sending mail to the content filter. So generally, it should
NOT be the "smtp" transport. Even if in practice all mail leaving
your system is single recipient as a result of the content filter.

I used to call the filter transport "scan", and in my case adjust
the "scan_destination_recipient_limit = 1000" (higher than the
default 50) so as to avoid wasting CPU on multiple scans of a single
messages sent to 1000 recipients (the smtpd_recipient_limit).

Your case is the other extreme, but make the intent of the setting
clear to others looking at your configuration by choosing a suitably
descriptive transport name for the content fitler stage.

This has the side-effect of changing the round-robin strategy when
volume is high from one queue per nexthop to one queue per recipient
address. Thus with:

        content_filter = smtp:[127.0.0.1]:10025

with the recipient limit > 1 there is a single queue with FIFO
delivery, but with the limit = 1, there are multiple queues with
messages going out round-robin by recipient and FIFO for a given
recipient. Because the queues are now per-recipient you probably
should reduce the "concurrency" limit, which now controls how many
simultaneous deliveries are bound for a single recipient, for example:

        <transport>_destination_concurrency_limit = 2

is the concurrency limit for the "local" transport, which is by
default a one recipient per delivery transport.

The above description of the scheduling strategy is only approximate
because the now default "new" queue manager implements a rather
complex pre-emption strategy to prevent a single message with lots
of recipients hogging the queue. So you have a substantial volume
of messages with large recipient counts (mailing list traffic)
mixed in with smaller messages, the scheduler is too complex to
explain here see

        http://www.postfix.org/SCHEDULER_README.html#jobs

if you're feeling brave (this is perhaps developer design documentation
rather than user documentation and is not an easy read).

> > For example:
> >
> > main.cf:
> > content_filter = cf_smtp
> > cf_smtp_destination_recipient_limit = 1
> >
> > master.cf:
> > cf_smtp unix ... smtp

Do use a sensible custom transport such as "scan", "cf_smtp", ...
whatever makes most sense in your environment.

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Split multiple recipient mail

maddog
This post has NOT been accepted by the mailing list yet.
In reply to this post by Thomas Spycher
Hi,
I know that this is a quiet old post but I have a similar issue.
My postfix is configured as open relay and once it receives an email with multiple addresses in the TO field , it should one copy of the received email for each address.
If I put smtp_recipient_limit =1 what happens is that the message is sent to the first address in the TO field as many times as the number of email address are present in that field.
Eg .
if it receives an email with:
test1@domain1;test2@domain1;test3@domain1
test1 receives the same email three times and other don't receive nothing.

Any help?


Thanks a lot


Carlo