Customize bounce template for mailserver
The default template tells you to "please send mail to postmaster" which isn't very actionable (what's the postmaster?). This directs people to a place where they can actually get help.
Jeremy Fleischman committed
Nov 9, 2024 at 12:26 UTC
e0814c9fd69170106d71cd15e8d1d7512a593c84
1 file changed
+49
-1
non-critical-infra/modules/mailserver/default.nix
+49
-1
@@ -1,4 +1,4 @@
1
-{ config, ... }:
1
+{ config, pkgs, ... }:
2
3
{
4
imports = [ ./mailing-lists.nix ];
@@ -34,4 +34,52 @@
34
loginAccount.encryptedHashedPassword = ../../secrets/test-sender-email-login.umbriel;
35
};
36
};
37
+
38
+ services.postfix.config.bounce_template_file = "${pkgs.writeText "bounce-template.cf" ''
39
+ failure_template = <<EOF
40
+ Charset: us-ascii
41
+ From: MAILER-DAEMON (Mail Delivery System)
42
+ Subject: Undelivered Mail Returned to Sender
43
+ Postmaster-Subject: Postmaster Copy: Undelivered Mail
44
+
45
+ This is the mail system at host $myhostname.
46
+
47
+ I'm sorry to have to inform you that your message could not
48
+ be delivered to one or more recipients. It's attached below.
49
+
50
+ For further assistance, please file an issue at
51
+ https://github.com/NixOS/infra/issues/new. Please anonymize any personal
52
+ email addresses in your report.
53
+
54
+ If you do so, please include this problem report. You can
55
+ delete your own text from the attached returned message.
56
+
57
+ The mail system
58
+ EOF
59
+
60
+ delay_template = <<EOF
61
+ Charset: us-ascii
62
+ From: MAILER-DAEMON (Mail Delivery System)
63
+ Subject: Delayed Mail (still being retried)
64
+ Postmaster-Subject: Postmaster Warning: Delayed Mail
65
+
66
+ This is the mail system at host $myhostname.
67
+
68
+ ####################################################################
69
+ # THIS IS A WARNING ONLY. YOU DO NOT NEED TO RESEND YOUR MESSAGE. #
70
+ ####################################################################
71
+
72
+ Your message could not be delivered for more than $delay_warning_time_hours hour(s).
73
+ It will be retried until it is $maximal_queue_lifetime_days day(s) old.
74
+
75
+ For further assistance, please file an issue at
76
+ https://github.com/NixOS/infra/issues/new. Please anonymize any personal
77
+ email addresses in your report.
78
+
79
+ If you do so, please include this problem report. You can
80
+ delete your own text from the attached returned message.
81
+
82
+ The mail system
83
+ EOF
84
+ ''}";
85
}