DevHeads.net

Feature request: More variables in smtpd_reject_footer

It would be nice if smtpd_reject_footer could include variables such as
the 4.x.x/5.x.x response code or even the full postfix error message,
this way one could make more helpful errors messages with more helpful
links.

Thanks

Comments

Re: Feature request: More variables in smtpd_reject_footer

By Viktor Dukhovni at 08/09/2018 - 11:24

Why would you want to duplicate this in the text of the reply, if
it already appears at the start of each response line??? It does
seem rather pointless...

Re: Feature request: More variables in smtpd_reject_footer

By Tom Sommer at 08/09/2018 - 11:52

On 2018-08-09 18:24, Viktor Dukhovni wrote:
So I can do a "Please look at
http://example.com/smtp.php?code=$smtp_code" and do some magic on that
page with the error code and/or error description to help the customer.

I don't think that is too far fetched?

Re: Feature request: More variables in smtpd_reject_footer

By Viktor Dukhovni at 08/09/2018 - 12:07

Seems like overkill. Will you be documenting all the Postfix
built-in error codes? If the error is from an access map, you can
already put an URL in the text.

That said, it is now clear what you're looking for. Presumably you
mostly want the enhanced status code, since otherwise it is mostly
just 554 for pretty much everything. Someone would have to write
the that, and cycles are rather limited. Unless you're able to
contribute a high-quality patch with updated documentation, this
is unlikely to appear soon...

Re: Feature request: More variables in smtpd_reject_footer

By Wietse Venema at 08/09/2018 - 12:31

Viktor Dukhovni:
I suggested using a lookup table (smtpd_reply_footer_maps) which
is queried with the original Postfix response, and which can
dynamically return a filled-in template based on the content of the
query string. A pcre map would be fine for that.

The only new code needed is to get the reply_footer from a table
instead of a main.cf variable. There are already lots of examples
of doing that in Postfix, so anyone could write that.

Wietse

Re: Feature request: More variables in smtpd_reject_footer

By Tom Sommer at 08/09/2018 - 12:37

On 2018-08-09 19:31, Wietse Venema wrote:
I see what you mean now, using the SMTP code as the lookup - I didn't
understand what you meant before.

Yes that would also work.

Re: Feature request: More variables in smtpd_reject_footer

By Wietse Venema at 08/09/2018 - 12:52

Tom Sommer:
is queried with the original Postfix response". These are different
things.

Please fix your MUA to respect the Reply-To: header, instead of
replying to me and owner-postfix-users.

Wietse

Re: Feature request: More variables in smtpd_reject_footer

By Tom Sommer at 08/10/2018 - 03:28

On 2018-08-09 19:52, Wietse Venema wrote:
What are the odds of smtpd_reply_footer_maps being added? :)

Done, apparently there was an option:
<a href="https://github.com/roundcube/roundcubemail/blob/0f7cdcc846391a1a2d934a6c6505337846ca811c/config/defaults.inc.php#L1253" title="https://github.com/roundcube/roundcubemail/blob/0f7cdcc846391a1a2d934a6c6505337846ca811c/config/defaults.inc.php#L1253">https://github.com/roundcube/roundcubemail/blob/0f7cdcc846391a1a2d934a6c...</a>

Re: Feature request: More variables in smtpd_reject_footer

By Wietse Venema at 08/10/2018 - 06:03

Tom Sommer:
Like, yesterday on the train home? It took one extra line in an
existing IF statement to try getting the template from a lookup
table before trying to get it from main.cf (still need to make the
corresponding change to postscreen).

Software, the unbounded potential to mess up.

Wietse

Re: Feature request: More variables in smtpd_reject_footer

By Tom Sommer at 08/09/2018 - 12:23

On 2018-08-09 19:07, Viktor Dukhovni wrote:
There are plenty of errors where customers/users need more information
or help as to what could have gone wrong and tips to troubleshooting -
even for something as simple as "invalid recipient" or "unknown domain".

Many SMTP-services send links with all their errors now, because they
are easily clickable in mail programs. I just want/wanted to do
something similar with Postfix :)

Re: Feature request: More variables in smtpd_reject_footer

By Wietse Venema at 08/09/2018 - 07:01

Tom Sommer:
Better: smtpd_reject_footer_maps. Then you can use a lookup
table (pcre or regexp etc.) to choose the footer dynamically.

It's also less work to implement. Postfix already has tons of example
where it gets a string from a table instead of main.cf variable.
The code that actually adds the footer won't need to be changed.

Wietse

Re: Feature request: More variables in smtpd_reject_footer

By Tom Sommer at 08/09/2018 - 07:08

On 2018-08-09 14:01, Wietse Venema wrote:
How that would enable me to dynamically add the relevant 4XX/5XX or
error for that mail into the text?

Example:
smtpd_reject_footer = \c See
example.com/errors?code=$responsecode&text=$errormsg

Re: Feature request: More variables in smtpd_reject_footer

By Wietse Venema at 08/09/2018 - 07:10

Tom Sommer:
RTFM:

This feature supports the two-character sequence \n as a request for a
line break in the footer text. Postfix automatically inserts after each
line break the three-digit SMTP reply code (and optional enhanced sta-
tus code) from the original Postfix reject message.

Attention span, attention span :-(

Wietse

Re: Feature request: More variables in smtpd_reject_footer

By Tom Sommer at 08/09/2018 - 07:50

On 2018-08-09 14:10, Wietse Venema wrote:
I did RTFM, I also read the source-code, the tests in
smtp_reply_footer() and the smtpd_expand_lookup() function, which seem
to limit the contents of smtpd_reject_footer to only a few variables.

I still fail to see how to inject the $smtp_code for the stream into the
string at a precise position, but I gather it's possible somehow so I
will keep digging.

Thanks, and sorry for the upset

Re: Feature request: More variables in smtpd_reject_footer

By Wietse Venema at 08/09/2018 - 07:57

Tom Sommer:
One more time:
YOU don't insert status codes into the footer.
POSTFIX inserts those for you.

Wietse

Re: Feature request: More variables in smtpd_reject_footer

By Tom Sommer at 08/09/2018 - 08:01

On 2018-08-09 14:57, Wietse Venema wrote:
Okay, so then we are back to my original feature request and me not
understanding how a smtpd_reject_footer_maps would enable me to do so :)

Sorry for the noise, I guess.

Re: Feature request: More variables in smtpd_reject_footer

By Wietse Venema at 08/09/2018 - 11:17

Tom Sommer:
For those who find this thread via a search engine.
You specify "\n" in the reply footer text.
Postfix replaces that with:
1 - One line break plus
2 - One SMTP reply code plus
3 - One optional enhanced status code.

Wietse

Re: Feature request: More variables in smtpd_reject_footer

By Tom Sommer at 08/09/2018 - 11:57

On 2018-08-09 18:17, Wietse Venema wrote:
That won't do what I am describing

This:

smtpd_reject_footer = Please visit http://example.com/error.php?code=\n
for more information

Will produce:

500-5.5.5 Please visit <a href="http://example.com/error.php?code=" title="http://example.com/error.php?code=">http://example.com/error.php?code=</a>
500 5.5.5 for more information