Hi, We have a client that expects that customer facing error messages are in the mother tongue of its customers. smtpd_reject_footer and smtpd_reject_footer_maps don't fully make the job because these parameters add a footer and don't replace the original text (yes, like the name of the parameters can suggest !).
Like the special '\c' first character that has a special behavior in the template, we have added a special '\r' first character that has the special behavior to replace the original reply text by the template text. Below is the patch for this feature (against 3.4.7, I can provide a patch for latest 3.5 snapshot if you prefer), I hope it will be useful for someone else. --- a/src/global/smtp_reply_footer.c +++ b/src/global/smtp_reply_footer.c @@ -170,6 +170,10 @@ int smtp_reply_footer(VSTRING *buffer, ssize_t start, if (cp == saved_template && strncmp(cp, "\\c", 2) == 0) { /* Handle \c at start of template. */ cp += 2; + } else if (cp == saved_template && strncmp(cp, "\\r", 2) == 0) { + /* Handle \r at start of template. */ + vstring_truncate(buffer, dsn_offs + dsn_len + 1); + cp += 2; } else { /* Append a clone of the SMTP reply code. */ vstring_strcat(buffer, "\r\n"); --- a/proto/postconf.proto +++ b/proto/postconf.proto @@ -15356,6 +15356,26 @@ is output literally. </p> client (192.168.1.248) and server (mail1.example.com). </pre> +<p> This another example uses "\r" at the start of the template +(supported in Postfix 3.5 and later) to replace the reply text +by the footer text. With earlier Postfix versions, the footer text always +begins after the reply text, and the "\r" is output literally. +This feature has a better usage with smtpd_reject_footer_maps. </p> + +<pre> +/etc/postfix/main.cf: + smtpd_reject_footer_maps = regexp:/etc/postfix/override_smtpd_replies.regexp + +/etc/postfix/override_smtpd_replies.regexp: + /^550 5.1.1 (<[^>]*>):/ \r$1: Adresse destinataire invalide +</pre> + +<p> Server response: </p> + +<pre> + 550 5.1.1 <f...@example.com>: Adresse destinataire invalide +</pre> + <p> Note: the above text is meant to make it easier to find the Postfix logfile records for a failed SMTP session. The text itself Regards -- Sébastien Michel Worldline Mobility & e-Transactional Services