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 5051e2f
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 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,50 @@
# 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
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
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 5051e2f

Please sign in to comment.