On Thu, Nov 04, 2021 at 12:28:33PM -0700, sru...@gemneye.org wrote: > On 2021-11-04 11:20, Viktor Dukhovni wrote: > > # This only matches valid multi-label DNS names. What should > > happen > > # with invalid forms (e.g., <user@foo.-bar>, <user@-foo+bar.net>)? > > # > > if !/@other\.domain$/ > > /^(.*)@([a-z0-9](-*[a-z0-9]+)*)\.[a-z0-9]/ ${1}+${2}@other.domain > > endif > > This appears to do exactly what I am wanting, so thank you for that. > What is unclear, is if this is the correct way to handle the issue. > Should this be done with smtp_generic_map instead? > > Thank you for taking the time to respond and providing a working > solution!
This is an acceptable work-around for an internal mailhub forwarding mail from sloppily/un configured internal machines. To really dot the i's and cross the t's, it should be hardened to also handle quoted address forms: "non..dot<atom>"@some.sub.domain -> "non..dot<atom>+some"@other.doamain via: if !/@other\.domain$/ /^"(.*)"@([a-z0-9](-*[a-z0-9]+)*)\.[a-z0-9]/ "${1}+${2}"@other.domain /^(.*)@([a-z0-9](-*[a-z0-9]+)*)\.[a-z0-9]/ ${1}+${2}@other.domain endif With quoted localpart addresses, the entire localpart needs to be in quotes. -- Viktor.