determine transport based on sender and receiver

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

determine transport based on sender and receiver

Patrick Landolt
I try to get a setup like to following ready:

1. I have multiple ip postfix should be able to send mails to other MTA
2. I setup different transport in master.cf each with a smtp_bind_address corresponding to a single ip
so far, so good! that setup already works

But now I need to handle slow ISPs like yahoo etc. My first try is to add transport_maps with like
yahoo.com slow:

But with that the transport changes to slow regardless on which transport it was before with sender_dependent_default_transport_maps and therefore the message is not sent by the correct ip address.

I now have 4 transports defined which are:
* m1
* m2-slow
* m2
* m2-slow

If i connect to m1.mxsend.ch it should deliver the message with transport m1 (done my mysql sender_dependent_default_transport_maps) and when connected to m2.mxsend.ch it should deliver the message with transport m2. This is working. But I cant find a solution to determine the transport regarding sender AND receiver of a message like that:
- sender is @m1.mxsend.ch and receiver is [hidden email] > use transport m1
- sender is @m1.mxsend.ch and receiver is [hidden email]   > use transport m1-slow
- sender is @m2.mxsend.ch and receiver is [hidden email] > use transport m2
- sender is @m2.mxsend.ch and receiver is [hidden email]   > use transport m2-slow


Following my setup
main.cf (postconf -n):
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
anvil_rate_time_unit = 60s
anvil_status_update_time = 600s
append_dot_mydomain = no
biff = no
bounce_queue_lifetime = 3d
broken_sasl_auth_clients = yes
debug_peer_level = 2
debug_peer_list = 5.102.146.19
html_directory = /usr/share/doc/postfix/html
inet_interfaces = all
inet_protocols = ipv4
m1-slow_destination_concurrency_failed_cohort_limit = 100
m1-slow_destination_concurrency_limit = 4
m1-slow_destination_concurrency_positive_feedback = 1/35
m1-slow_initial_destination_concurrency = 1
m2-slow_destination_concurrency_failed_cohort_limit = 100
m2-slow_destination_concurrency_limit = 1
m2-slow_initial_destination_concurrency = 1
mailbox_size_limit = 0
maximal_queue_lifetime = 3d
message_size_limit = 20480000
milter_default_action = accept
milter_protocol = 2
mydestination = $myhostname, localhost.$myhostname, localhost
mydomain = mxsend.ch
myhostname = m1
mynetworks = 127.0.0.0/8 5.102.146.19 5.102.145.149 5.102.151.226
myorigin = $myhostname
non_smtpd_milters = inet:localhost:12301
readme_directory = /usr/share/doc/postfix
recipient_delimiter = +
sender_dependent_default_transport_maps = mysql:/etc/postfix/mysql_sender_dependent_default_transport_maps.cf
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name
smtpd_client_connection_count_limit = 0
smtpd_client_connection_rate_limit = 0
smtpd_client_event_limit_exceptions =
smtpd_error_sleep_time = 1s
smtpd_hard_error_limit = 2000
smtpd_milters = inet:localhost:12301
smtpd_recipient_restrictions = reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauthenticated_sender_login_mismatch permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_soft_error_limit = 1000
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
transport_maps = mysql:/etc/postfix/mysql_transport_maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /var/spool/maildirs
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_mailbox_domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 5000
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_uid_maps = static:5000

master.cf (postconf -P):
m1/unix/smtp_bind_address = 5.102.145.149
m1/unix/smtp_helo_name = m1.mxsend.ch
m1/unix/syslog_name = postfix-m1
m2/unix/smtp_bind_address = 5.102.151.226
m2/unix/smtp_helo_name = m2.mxsend.ch
m2/unix/syslog_name = postfix-m2
m1-slow/unix/smtp_bind_address = 5.102.145.149
m1-slow/unix/smtp_helo_name = m1.mxsend.ch
m1-slow/unix/syslog_name = postfix-m1-slow
m2-slow/unix/smtp_bind_address = 5.102.151.226
m2-slow/unix/smtp_helo_name = m2.mxsend.ch
m2-slow/unix/syslog_name = postfix-m2-slow
5.102.145.149:smtp/inet/myhostname = m1.mxsend.ch
5.102.145.149:submission/inet/myhostname = m1.mxsend.ch
5.102.151.226:smtp/inet/myhostname = m2.mxsend.ch
5.102.151.226:submission/inet/myhostname = m2.mxsend.ch

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: determine transport based on sender and receiver

Wietse Venema
Patrick Landolt:
> I try to get a setup like to following ready:
>
> 1. I have multiple ip postfix should be able to send mails to other MTA
> 2. I setup different transport in master.cf each with a smtp_bind_address corresponding to a single ip
> so far, so good! that setup already works
>
> But now I need to handle slow ISPs like yahoo etc. My first try is to add transport_maps with like
> yahoo.com slow:

This requires support for multiple criteria, in this case sender
and recipient. The only place that currently does this in Postfix
is the SMTP server policy protocol, which is implemented before
mail is queued. A sane implementation of what you want should be
done post-queue.

Strawman transport_policy:
- The client is implemented in the trivial-rewrite service.
- The protocol format is like the SMTP policy protocol: one line
  per name=value attribute. This easy to parse in any language.
- The request contains one sender, one recipient, and perhaps other
  information.
- The service replies with one transport, one nexthop, and one
  recipient.
- Open question: how are the client requests placed in time relative
  to transport_maps, sender_dependent_mumble_maps, and other routing
  features?

        Wietse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: determine transport based on sender and receiver

Patrick Landolt
Thank you taking the time to answer my question. Unfortunately I have
no idea what you mean. May you point me to some documentation that
I can follow and understand your answer?

Regards,
Patrick


> On 22 Jun 2017, at 17:28, Wietse Venema <[hidden email]> wrote:
>
> Patrick Landolt:
>> I try to get a setup like to following ready:
>>
>> 1. I have multiple ip postfix should be able to send mails to other MTA
>> 2. I setup different transport in master.cf each with a smtp_bind_address corresponding to a single ip
>> so far, so good! that setup already works
>>
>> But now I need to handle slow ISPs like yahoo etc. My first try is to add transport_maps with like
>> yahoo.com slow:
>
> This requires support for multiple criteria, in this case sender
> and recipient. The only place that currently does this in Postfix
> is the SMTP server policy protocol, which is implemented before
> mail is queued. A sane implementation of what you want should be
> done post-queue.
>
> Strawman transport_policy:
> - The client is implemented in the trivial-rewrite service.
> - The protocol format is like the SMTP policy protocol: one line
>  per name=value attribute. This easy to parse in any language.
> - The request contains one sender, one recipient, and perhaps other
>  information.
> - The service replies with one transport, one nexthop, and one
>  recipient.
> - Open question: how are the client requests placed in time relative
>  to transport_maps, sender_dependent_mumble_maps, and other routing
>  features?
>
> Wietse

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: determine transport based on sender and receiver

Fazzina, Angelo
Hi Patrick,
Not sure this is helpful but I searched the archives and found this.

http://marc.info/?l=postfix-users&m=148063002508453&w=2

maybe brush up on the doc of transport config file options ?

Good luck.
-ALF

-Angelo Fazzina
Operating Systems Programmer / Analyst
University of Connecticut,  UITS, SSG, Server Systems
860-486-9075

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Patrick Landolt
Sent: Thursday, June 22, 2017 2:29 PM
To: Postfix users <[hidden email]>
Subject: Re: determine transport based on sender and receiver

Thank you taking the time to answer my question. Unfortunately I have
no idea what you mean. May you point me to some documentation that
I can follow and understand your answer?

Regards,
Patrick


> On 22 Jun 2017, at 17:28, Wietse Venema <[hidden email]> wrote:
>
> Patrick Landolt:
>> I try to get a setup like to following ready:
>>
>> 1. I have multiple ip postfix should be able to send mails to other MTA
>> 2. I setup different transport in master.cf each with a smtp_bind_address corresponding to a single ip
>> so far, so good! that setup already works
>>
>> But now I need to handle slow ISPs like yahoo etc. My first try is to add transport_maps with like
>> yahoo.com slow:
>
> This requires support for multiple criteria, in this case sender
> and recipient. The only place that currently does this in Postfix
> is the SMTP server policy protocol, which is implemented before
> mail is queued. A sane implementation of what you want should be
> done post-queue.
>
> Strawman transport_policy:
> - The client is implemented in the trivial-rewrite service.
> - The protocol format is like the SMTP policy protocol: one line
>  per name=value attribute. This easy to parse in any language.
> - The request contains one sender, one recipient, and perhaps other
>  information.
> - The service replies with one transport, one nexthop, and one
>  recipient.
> - Open question: how are the client requests placed in time relative
>  to transport_maps, sender_dependent_mumble_maps, and other routing
>  features?
>
> Wietse

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: determine transport based on sender and receiver

Patrick Landolt
Hi Angelo

In the end the solution behind your link is what I already tried to achieve. But I
cant only check for the destination (receiver) address. I need a combination of
sender and receiver address to determine the transport which is to be used.

Regards,
Patrick

> On 22 Jun 2017, at 20:38, Fazzina, Angelo <[hidden email]> wrote:
>
> Hi Patrick,
> Not sure this is helpful but I searched the archives and found this.
>
> http://marc.info/?l=postfix-users&m=148063002508453&w=2
>
> maybe brush up on the doc of transport config file options ?
>
> Good luck.
> -ALF
>
> -Angelo Fazzina
> Operating Systems Programmer / Analyst
> University of Connecticut,  UITS, SSG, Server Systems
> 860-486-9075
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Patrick Landolt
> Sent: Thursday, June 22, 2017 2:29 PM
> To: Postfix users <[hidden email]>
> Subject: Re: determine transport based on sender and receiver
>
> Thank you taking the time to answer my question. Unfortunately I have
> no idea what you mean. May you point me to some documentation that
> I can follow and understand your answer?
>
> Regards,
> Patrick
>
>
>> On 22 Jun 2017, at 17:28, Wietse Venema <[hidden email]> wrote:
>>
>> Patrick Landolt:
>>> I try to get a setup like to following ready:
>>>
>>> 1. I have multiple ip postfix should be able to send mails to other MTA
>>> 2. I setup different transport in master.cf each with a smtp_bind_address corresponding to a single ip
>>> so far, so good! that setup already works
>>>
>>> But now I need to handle slow ISPs like yahoo etc. My first try is to add transport_maps with like
>>> yahoo.com slow:
>>
>> This requires support for multiple criteria, in this case sender
>> and recipient. The only place that currently does this in Postfix
>> is the SMTP server policy protocol, which is implemented before
>> mail is queued. A sane implementation of what you want should be
>> done post-queue.
>>
>> Strawman transport_policy:
>> - The client is implemented in the trivial-rewrite service.
>> - The protocol format is like the SMTP policy protocol: one line
>> per name=value attribute. This easy to parse in any language.
>> - The request contains one sender, one recipient, and perhaps other
>> information.
>> - The service replies with one transport, one nexthop, and one
>> recipient.
>> - Open question: how are the client requests placed in time relative
>> to transport_maps, sender_dependent_mumble_maps, and other routing
>> features?
>>
>> Wietse
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: determine transport based on sender and receiver

Viktor Dukhovni
On Thu, Jun 22, 2017 at 08:45:31PM +0200, Patrick Landolt wrote:

> Hi Angelo
>
> In the end the solution behind your link is what I already tried to achieve. But I
> cant only check for the destination (receiver) address. I need a combination of
> sender and receiver address to determine the transport which is to be used.

Postfix can't presently do that in a single hop.  You can only do
this in a two-stage Postfix deployment.  The first stage would
de-multiplex incoming mail into multiple streams, one per output
IP address, and the second stage Postfix instances (one per output
address) would then de-multiplex by destination domain.

--
        Viktor.
Loading...