Skip to content

Commit

Permalink
Customize bounce template for mailserver
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jfly committed Nov 9, 2024
1 parent 8edb8de commit 5633478
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion non-critical-infra/modules/mailserver/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, ... }:
{ config, pkgs, ... }:

{
imports = [ ./mailing-lists.nix ];
Expand All @@ -16,4 +16,52 @@
# TODO: change to `nixos.org` when ready
domains = [ "mail-test.nixos.org" ];
};

services.postfix.config.bounce_template_file = "${pkgs.writeText "bounce-template.cf" ''
failure_template = <<EOF
Charset: us-ascii
From: MAILER-DAEMON (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
Postmaster-Subject: Postmaster Copy: Undelivered Mail
This is the mail system at host $myhostname.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please file an issue at
https://github.com/NixOS/infra/issues/new. Please anonymize any personal
email addresses in your report.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
EOF
delay_template = <<EOF
Charset: us-ascii
From: MAILER-DAEMON (Mail Delivery System)
Subject: Delayed Mail (still being retried)
Postmaster-Subject: Postmaster Warning: Delayed Mail
This is the mail system at host $myhostname.
####################################################################
# THIS IS A WARNING ONLY. YOU DO NOT NEED TO RESEND YOUR MESSAGE. #
####################################################################
Your message could not be delivered for more than $delay_warning_time_hours hour(s).
It will be retried until it is $maximal_queue_lifetime_days day(s) old.
For further assistance, please file an issue at
https://github.com/NixOS/infra/issues/new. Please anonymize any personal
email addresses in your report.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
EOF
''}";
}

0 comments on commit 5633478

Please sign in to comment.