opensmtpd-filter-rewrite-from
opensmtpd-filter-rewrite-from copied to clipboard
OpenSMTPD 6.6+ filter for rewriting From address
= OpenSMTPD filter-rewrite-from :script-name: filter-rewrite-from
This is a very simple OpenSMTPD filter for rewriting email address in both MAIL FROM
command and From
header in all footnote:[This implementation doesn’t support any conditions or different rewrite addresses based on the source. It’s really trivial, just for my current needs.] messages with the specified email address.
It’s useful when you want to ensure that all the relayed messages will be “send from” some no-reply email address.
This filter is implemented in ~60 lines (LoC) of awk
.
== Requirements
- http://pubs.opengroup.org/onlinepubs/009695399/utilities/awk.html[POSIX awk] (e.g. from Busybox, GNU, BSD, …)
- https://www.opensmtpd.org/[OpenSMTPD] 6.6.0 or higher
== Installation
Just copy link:{script-name}[{script-name}] to some directory, e.g. /usr/local/share/opensmtpd
.
If you have awk
installed in a different directory than /usr/bin
, adjust the shebang.
== Configuration
The filter itself requires no configuration, only the desired From email address as the first argument.
It must be declared in smtpd.conf and attached to a listener:
[source, subs="+attributes"]
filter "rewrite-from" proc-exec "/usr/local/share/opensmtpd/{script-name} [email protected]"
listen on socket filter "rewrite-from"
== See Also
- https://poolp.org/posts/2018-11-03/opensmtpd-released-and-upcoming-filters-preview/[OpenSMTPD released and upcoming filters preview] by https://github.com/poolpOrg[Gilles Chehade]
- https://poolp.org/posts/2019-07-27/july-2019-report-tons-of-smtpd-work-mostly/[July 2019 report: tons of smtpd work mostly] by https://github.com/poolpOrg[Gilles Chehade]
== License
This project is licensed under http://opensource.org/licenses/ISC/[ISC License]. For the full text of the license, see the link:LICENSE[LICENSE] file.