To enable TLSRPT, define a DNS record at _smtp._tls.yourdomain.name
. Refer to RFC8460 for the policy syntax. Basically, you decide whether you want to receive reports via mail or via web. Why would you want to receive them? And why would you want to use this script, or a similar one?
After enabling it, some mail domains are going to send you daily reports saying that everything is well. However, if you block access to spammers at the connection level, using tools such as fail2ban or ipqbdb, you'll happen to block some too-big-to-block (TBTB) senders. TLSRPT allows those senders to notify you that a TLS connection attempt failed, providing the IP address(es) that you may want to redeem.
The present script reads the report attached to the input message, looking for failures. If it finds any, it adds a special header field, TLS-Report-Has-Failures
that you can check in your mail filter in order to redirect the message to some additional recipients/ folders where it can catch your attention. It also extracts noteworthy information, so that you don't have to open the compressed attachment.
Of course, redeeming TBTB addresses is not the only use TLSRPT provides. For example, you can derive statistics to be compared with DMARC reports.
Copy and paste the script to your editor of choice. Note that it uses \n
line endings. Add \r
if needed. Also, the script writes to stderr
. You may want to replace that with syslog if your filter doesn't do that for you. You may also want to tweak email.policy. When you're done, save the file where your mail filter can reach it.
Copyright (C) 2022-2024 Alessandro Vesely, all rights reserved except as noted.