Feature request: More variables in smtpd_reject_footer

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Feature request: More variables in smtpd_reject_footer

Tom Sommer
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
--
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Wietse Venema
Tom Sommer:
> 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.

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
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Tom Sommer
On 2018-08-09 14:01, Wietse Venema wrote:
> Tom Sommer:
>> 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.
>
> Better: smtpd_reject_footer_maps. Then you can use a lookup
> table (pcre or regexp etc.) to choose the footer dynamically.

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

--
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Wietse Venema
Tom Sommer:

> On 2018-08-09 14:01, Wietse Venema wrote:
> > Tom Sommer:
> >> 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.
> >
> > Better: smtpd_reject_footer_maps. Then you can use a lookup
> > table (pcre or regexp etc.) to choose the footer dynamically.
>
> How that would enable me to dynamically add the relevant 4XX/5XX or
> error for that mail into the text?

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
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Tom Sommer
On 2018-08-09 14:10, Wietse Venema wrote:

> Tom Sommer:
>> On 2018-08-09 14:01, Wietse Venema wrote:
>> > Tom Sommer:
>> >> 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.
>> >
>> > Better: smtpd_reject_footer_maps. Then you can use a lookup
>> > table (pcre or regexp etc.) to choose the footer dynamically.
>>
>> How that would enable me to dynamically add the relevant 4XX/5XX or
>> error for that mail into the text?
>
> 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 :-(

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
--
Tom Sommer
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Wietse Venema
Tom Sommer:

> On 2018-08-09 14:10, Wietse Venema wrote:
> > Tom Sommer:
> >> On 2018-08-09 14:01, Wietse Venema wrote:
> >> > Tom Sommer:
> >> >> 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.
> >> >
> >> > Better: smtpd_reject_footer_maps. Then you can use a lookup
> >> > table (pcre or regexp etc.) to choose the footer dynamically.
> >>
> >> How that would enable me to dynamically add the relevant 4XX/5XX or
> >> error for that mail into the text?
> >
> > 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 :-(
>
> 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.

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

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Tom Sommer
On 2018-08-09 14:57, Wietse Venema wrote:
> Tom Sommer:
>> 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.
>
> One more time:
> YOU don't insert status codes into the footer.
> POSTFIX inserts those for you.

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.
--
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Wietse Venema
Tom Sommer:

> On 2018-08-09 14:57, Wietse Venema wrote:
> > Tom Sommer:
> >> 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.
> >
> > One more time:
> > YOU don't insert status codes into the footer.
> > POSTFIX inserts those for you.
>
> 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.

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
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Viktor Dukhovni
In reply to this post by Tom Sommer
On Thu, Aug 09, 2018 at 11:07:33AM +0200, Tom Sommer wrote:

> 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.

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...

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Tom Sommer
On 2018-08-09 18:24, Viktor Dukhovni wrote:

> On Thu, Aug 09, 2018 at 11:07:33AM +0200, Tom Sommer wrote:
>
>> 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.
>
> 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...

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?

--
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Tom Sommer
In reply to this post by Wietse Venema
On 2018-08-09 18:17, Wietse Venema wrote:

> Tom Sommer:
>> On 2018-08-09 14:57, Wietse Venema wrote:
>> > Tom Sommer:
>> >> 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.
>> >
>> > One more time:
>> > YOU don't insert status codes into the footer.
>> > POSTFIX inserts those for you.
>>
>> 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.
>
> 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.

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 http://example.com/error.php?code=
500 5.5.5 for more information

---
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Viktor Dukhovni
In reply to this post by Tom Sommer
On Thu, Aug 09, 2018 at 06:52:48PM +0200, Tom Sommer 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.

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...

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Tom Sommer
On 2018-08-09 19:07, Viktor Dukhovni wrote:
> On Thu, Aug 09, 2018 at 06:52:48PM +0200, Tom Sommer 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.
>
> Seems like overkill.  Will you be documenting all the Postfix
> built-in error codes?

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 :)

--
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Wietse Venema
In reply to this post by Viktor Dukhovni
Viktor Dukhovni:

> On Thu, Aug 09, 2018 at 06:52:48PM +0200, Tom Sommer 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.
>
> 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...

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
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Tom Sommer
On 2018-08-09 19:31, Wietse Venema wrote:

> Viktor Dukhovni:
>> On Thu, Aug 09, 2018 at 06:52:48PM +0200, Tom Sommer 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.
>>
>> 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...
>
> 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.

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.

---
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Wietse Venema
Tom Sommer:

> On 2018-08-09 19:31, Wietse Venema wrote:
> > Viktor Dukhovni:
> >> On Thu, Aug 09, 2018 at 06:52:48PM +0200, Tom Sommer 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.
> >>
> >> 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...
> >
> > 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.
>
> I see what you mean now, using the SMTP code as the lookup - I didn't
> understand what you meant before.

Correction: NOT using the SMTP code as the lookup. I wrote: "which
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
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Tom Sommer
On 2018-08-09 19:52, Wietse Venema wrote:

> Tom Sommer:
>> On 2018-08-09 19:31, Wietse Venema wrote:
>> > 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.
>>
>> I see what you mean now, using the SMTP code as the lookup - I didn't
>> understand what you meant before.
>
> Correction: NOT using the SMTP code as the lookup. I wrote: "which
> is queried with the original Postfix response". These are different
> things.

What are the odds of smtpd_reply_footer_maps being added? :)

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

Done, apparently there was an option:
https://github.com/roundcube/roundcubemail/blob/0f7cdcc846391a1a2d934a6c6505337846ca811c/config/defaults.inc.php#L1253

--
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: More variables in smtpd_reject_footer

Wietse Venema
Tom Sommer:

> On 2018-08-09 19:52, Wietse Venema wrote:
> > Tom Sommer:
> >> On 2018-08-09 19:31, Wietse Venema wrote:
> >> > 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.
> >>
> >> I see what you mean now, using the SMTP code as the lookup - I didn't
> >> understand what you meant before.
> >
> > Correction: NOT using the SMTP code as the lookup. I wrote: "which
> > is queried with the original Postfix response". These are different
> > things.
>
> What are the odds of smtpd_reply_footer_maps being added? :)

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).

> > Please fix your MUA to respect the Reply-To: header, instead of
> > replying to me and owner-postfix-users.
>
> Done, apparently there was an option:
> https://github.com/roundcube/roundcubemail/blob/0f7cdcc846391a1a2d934a6c6505337846ca811c/config/defaults.inc.php#L1253

Software, the unbounded potential to mess up.

        Wietse