[Pymilter] use py-milter to change the routing of a Mail
Stuart Gathman
stuart at gathman.org
Mon Aug 6 13:46:46 EDT 2018
On 08/06/2018 10:03 AM, Gerhard Schmidt wrote:
> Mailertable is for routing based on to: not on from:
>
> I'm trying to send a mail with a from: uuuu at xyz.com to the smarthost
> that is allowd to send @xyz.com mails regardless of the destination
> (to:) address. mails from vvvv at zyx.com will be routed over an different
> mailserver that is allowed to send mails for @zyx.com regardless about
> the destination of the Mail and so on.
Make sure you have reviewed
http://www.openspf.org/Best_Practices/Email_Service_Provider
Ok, I actually do routing based on MAIL FROM - but by using smtplib and
sending it from the milter. Any timeouts are reported back as 4xx.
This doesn't let sendmail queue any failures, however. My applications
route to various internal MTAs - which does not annoy any clients.
You can use pysrs to rewrite MAIL FROM with your own MAIL FROM, and
encoding your clients MAIL FROM with a timestamped signature in
localpart. Although why your clients would want to get any bounces
(DSNs) for emails they did not generate is beyond me.
https://github.com/sdgathman/pysrs
If your client is willing to give you a password on their MTA, they can
add your MTA to their sender policy. Maybe we need to talk about what
your ultimate goal is. As best I can guess, you will be generating
emails for your clients, but sending them via their own MTA. Normally,
the reason for outsourcing sending the email is to *avoid* using their
own MTA. Using the clients MTA to send the emails defeats the whole
purpose of hiring you to do the sending!
Assuming your clients really do want you to use their own MTAs to send
outsourced emails (and have to deal with DSNs from emails you generate),
you will need a socket map. Again, I do NOT recommend what you seem to
think you want to do.
Changing the routing in sendmail must be done in the CF configuration
(refer to the CF code for the mailertable feature) - similar to how
pysrs handles changing MAIL FROM (for multiple destinations - chgfrom in
the milter api affects all destinations). You will have a socket map
that sendmail consults to obtain the routing instead of mailertable.db
and authinfo.db, and your python socket server will respond with the
routing. The pysrs package can be your starting point, showing you
how to connect sendmail CF to a python socket map server.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://gathman.org/pipermail/pymilter/attachments/20180806/6e7b3b08/attachment.sig>
More information about the Pymilter
mailing list