Only rewrite sender when forwarding and dynamically exclude local domains #76
Replies: 19 comments 19 replies
-
Thanks for you're idea, I just use it a little bit different: main.cf:
regex_transport_srs: master.cf:
/regex_sender_canonical_srs: Remark: you could also make an opt-out solution like this, if you use the default transport .... |
Beta Was this translation helpful? Give feedback.
-
Hey, I really like your solutions! As soon as I find time, I will put them into the README. |
Beta Was this translation helpful? Give feedback.
-
@trefzer I'm trying use your configuration in clean installation of https://www.iredmail.org When I'm send message from yahoo -> local-alias -> gmail I don't have SRS headers at all. Here is my configuration in /etc/postfix/ two files:
in /etc/postfix/mysql
and in main.cnf
and master
|
Beta Was this translation helpful? Give feedback.
-
where does the local alias points to ? (it needs to point to srs=gmailaddress, otherwise the postsrs transport is not used. |
Beta Was this translation helpful? Give feedback.
-
For those who don't want to use a SQL server just for the list of local mail addresses that SRS shouldn't be used on, there's a simpler and faster way. Replace
with
Now add every existing local mail address to /etc/postfix/no_srs. Each entry looks like this:
If you already have a virtual_alias_maps file, then the no_srs table is not much different. Instead of returning the name of a local mailbox or an external mail address, no_srs returns the same address instead. A lookup hit therefore means to skip SRS (these table lookups basically simulate an already rewritten address, but in fact the address stays the same). A miss means that postsrsd is called next via
and the mail address is rewritten. Don't forget to create/update the lookup table (no_srs.db) after you modified no_srs with
|
Beta Was this translation helpful? Give feedback.
-
I installed postsrsd a few days ago and noticed all mail got SRS tagged and not just forwarded mail.
The port 8891 is my DKIM setup but if I remove the DKIM relevant settings in main.cf I still get the same error but for port 10002 |
Beta Was this translation helpful? Give feedback.
-
update on my previous post... |
Beta Was this translation helpful? Give feedback.
-
I believe you may have to change your http://www.postfix.org/postconf.5.html#relay_transport instead of default_transport |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply @chaosmaster , it looked promising... |
Beta Was this translation helpful? Give feedback.
-
@RhysMcW |
Beta Was this translation helpful? Give feedback.
-
Thanks, gave that a try, unfortunately no difference, still no SRS rewriting. |
Beta Was this translation helpful? Give feedback.
-
RhysMcW did you ever figure out your problem? I found this issue with great interest as it seemed like I should be able to use a similar technique to apply a content filter only to emails that come in on port 25 (but not 587) and which are being forwarded externally. I attempted to use '-o default_transport=smtp:127.0.0.1:10027' on the port 25 smtpd in master.cf, and then made a similar entry for the 127.0.0.1:10027 smtpd in master.cf as chaosmaster, but instead of setting cleanup_service_name, instead set content_filter to point to my content filter. But it is not working at all, no mail appears to be getting routed through 127.0.0.1:10027 or to my content filter. Previously I had added '-o content_filter=...' in the port 25 smtpd, and that worked but was applied to both locally delivered and forwarded mail. I currently suspect the issue with setting '-o default_transport=smtp:127.0.0.1:10027' in the port 25 smtpd is that the setting is used by a later process down the chain, and probably after mail from port 587 has merged into the processing chain. I'm going to play with some ideas around confirming that next, but thought I would post here first since it seems a few of you understand how postfix works much more deeply than I do, and have already been playing with ideas along these lines. |
Beta Was this translation helpful? Give feedback.
-
Having the same issue here. Trying to relay it to a different server, which is a spam filter, but no luck so far. |
Beta Was this translation helpful? Give feedback.
-
I decided I will need to create a multi-instance postfix configuration to do what I want but I think it will work. Unfortunately I have not had time to actually try it yet... |
Beta Was this translation helpful? Give feedback.
-
I think I am missing something, but why can we not just use the canonical_maps without the extra internal SMTPD hop? Is there a reason for having the extra SMTPD service?
This is my config (well I am using a hash:mailboxes instead of mysql), but I believe this is working just fine. I.e. I read this as, rewrite the sender address to the sender address if the mailbox exist, if not, we are using postsrsd. Anyone that can shine some light on why originally an extra SMTPD hop was introduced @chaosmaster? |
Beta Was this translation helpful? Give feedback.
-
Wouldn't that also rewrite the senders of all incoming mails? |
Beta Was this translation helpful? Give feedback.
-
You are correct... Refusing to give up, I started playing around with I mean, your solution still works great :) and it works perfectly. Just for future reference, I have: main.cf
master.cf
Note: smtpd_milters I put to empty to prevent rspamd from scanning twice |
Beta Was this translation helpful? Give feedback.
-
Hello everyone, If I past this on my master.cf my postfix won't restart "postfix/master[27350]: terminating on signal 15". If I removed the mysql query "mysql:/etc/postfix/mysql_virtual_local_email.cf" from the master.cf the postfix service is up.
Any ideas what I can do? I also used postfix with amavis for spam protection. In my main.cf I have this:
I have no default transport any ideas? |
Beta Was this translation helpful? Give feedback.
-
[SOLVED] - postsrsd v1 v2 forward and reverse and the answers to many questionsIMPORTANT NOTE:
situation:
↑↑ line breaks inserted for readability the final (?) solution :
/etc/postfix/virtual/mysql-no-srs.cf
/etc/postfix/regex_recipient_srs
v1/v2
non-virtual-setupwhen having a no-virtual-mail setup ( e.g. no mailboxes in the system and you are a smarthost for multiple senders ),
OR ( to have the PCRE and MYSQL checked):
and in the file /etc/postfix/regex_recipient_srs:
but only do this if you are certain .. NOTES:
NOTE²:when forwarding ,
FWD_DETAIL³:if you have a setup with virtual users you should only adjust the sql config query,
FWD_NOTES FLOPMAIL(hotmail) / outage365(office365) ( and other large providers ) :
02/23 queries + configs updated -> sorry if you already deployed .. the pcre/regexp is not allowed to return tcp:... , only match incoming/outgoing addresses or not as in the previous post version |
Beta Was this translation helpful? Give feedback.
-
A setup like this only rewrites the sender for mails going to external adresses
Additionally local domains are excluded from SRS
main.cf:
master.cf:
The query just returns the address if the domain is valid, and therefore doesn't map to an SRS-address
Beta Was this translation helpful? Give feedback.
All reactions