Re: Capture / Filter Remote Server Responses?

2015-05-20 Thread Michael Munger
tldr:

I want to be able to stick a filter / milter AFTER smtp(8) so I can
save the remote server response code and associate it with an email
that was sent so my PHP application can display the status of a
notification sent to a user.

Looking for docs on how to do this.


Long story / background / additional info:

I have an automated bug tracker that sends email notifications to
users when something they are working on needs their attention.

Sometimes, people complain they don't get the messages. So, I end up
going through mail.log to see what the problem is, and invariably, I
see the email was sent to their address with a 250 OK Queued as...
response, which means it's not my problem.

So, here's the question:

I would like to add a python script that would be able to read /
store the remote server responses for a given message. I will stuff
an X-Header into the mail before I send it so that the Python script
can associate the exact email with the exact notification that goes
out.

The point here, is that if a message with X-Header XYZ 1234 was
sent, and we received a 250 OK back from the remote server, we know
we've done everything we can to deliver the message. It's now
outside our network.

if, on the other hand, I get something like a 551 5.7.1, we know
that something is wrong and we've been classified as spam. Or, as I
recently saw with one of our users: 550 5.1.1 user unknown because
the user in question is unable to type their own email address
properly... .twice. (The form requires you confirm it, so they
really had to try to fail).

*If I can insert the python script as a filter (or milter?) AFTER
smtp(8), that would be perfect. I could read the X-header injected
by the PHP application to get the message ID as the PHP application
knows it by, and then read the response code to find out the
disposition of the message.*
**
Where in the docs can I find information on doing this?

Michael Munger, dCAP, MCPS, MCNPS, MBSS
High Powered Help, Inc.
Microsoft Certified Professional
Microsoft Certified Small Business Specialist
Digium Certified Asterisk Professional
mich...@highpoweredhelp.com


Re: Capture / Filter Remote Server Responses?

2015-05-20 Thread Wietse Venema
Michael Munger:
 This seems to get me about 80% of the way there. I can send from
 a specific mailbox, so the response will be delivered to that
 mailbox, and I can check it programmatically. So that's great.

 It still leaves me with the question of: how do I associate this
 particular reply with a notification that I sent? My initial idea
 was to use X-Header and stuff a unique ID in that header, so I
 could make the association, but this documentation appears to say:
 I'm not going to send you X-Headers back... or body content.

The documentation shows that Postfix sends the message HEADERS back. 

You can also specify an Envelope-ID on submission, and then you get
it back via the delivery status notification.

SENDMAIL(1) General Commands ManualSENDMAIL(1)
...
   -f sender
  Set the envelope sender  address.  This  is  the  address  where
  delivery problems are sent to. With Postfix versions before 2.1,
  the  Errors-To:  message  header  overrides  the  error   return
  address.
...
   -V envid
  Specify the envelope ID for notification by servers that support
  DSN.

See RFC 3461 for more information about the envelope ID.

Note that remote MTAs will report non-delivery or delays to the
same sender address that you use for reporting remote SMTP server
replies, though not all MTAs use the standardized format.

Wietse


RE: Capture / Filter Remote Server Responses?

2015-05-20 Thread Michael Munger
This seems to get me about 80% of the way there. I can send from a specific 
mailbox, so the response will be delivered to that mailbox, and I can check it 
programmatically. So that's great.

It still leaves me with the question of: how do I associate this particular 
reply with a notification that I sent? My initial idea was to use X-Header and 
stuff a unique ID in that header, so I could make the association, but this 
documentation appears to say: I'm not going to send you X-Headers back... or 
body content.

So, what are your suggestions on associating the reports to the original notif? 
Where can I stuff an ID to do this?

Michael Munger, dCAP, MCPS, MCNPS, MBSS
High Powered Help, Inc.
Microsoft Certified Professional
Microsoft Certified Small Business Specialist
Digium Certified Asterisk Professional
mich...@highpoweredhelp.com

-Original Message-
From: owner-postfix-us...@postfix.org [mailto:owner-postfix-us...@postfix.org] 
On Behalf Of Wietse Venema
Sent: Wednesday, May 20, 2015 11:03 AM
To: Postfix users
Subject: Re: Capture / Filter Remote Server Responses?

Michael Munger:
 tldr:
 
 I want to be able to stick a filter / milter AFTER smtp(8) so I can
 save the remote server response code and associate it with an email
 that was sent so my PHP application can display the status of a
 notification sent to a user.

Postfix has an option to record SMTP remote server responses, and to mail that 
back to the sender, formatted as a standard internet delivery status 
notification.

You request this with /usr/sbin/sendmail -v recipient  See 
http://www.postfix.org/ADDRESS_REWRITING_README.html#debugging
for an example and narrative text.

There currently is no option to request this in SMTP submissions.
This should be an access-restricted feature for obvious reasons.

Wietse


Re: Capture / Filter Remote Server Responses?

2015-05-20 Thread Michael Munger
Thank you very much.

I'll take it from here, and let you know how it goes. (I'll reply the
list with a how-to for future searchers).

On 05/20/2015 01:25 PM, Wietse Venema wrote:
 Michael Munger:
 This seems to get me about 80% of the way there. I can send from
 a specific mailbox, so the response will be delivered to that
 mailbox, and I can check it programmatically. So that's great.

 It still leaves me with the question of: how do I associate this
 particular reply with a notification that I sent? My initial idea
 was to use X-Header and stuff a unique ID in that header, so I
 could make the association, but this documentation appears to say:
 I'm not going to send you X-Headers back... or body content.
 The documentation shows that Postfix sends the message HEADERS back. 

 You can also specify an Envelope-ID on submission, and then you get
 it back via the delivery status notification.

 SENDMAIL(1) General Commands ManualSENDMAIL(1)
   ...
-f sender
   Set the envelope sender  address.  This  is  the  address  where
   delivery problems are sent to. With Postfix versions before 2.1,
   the  Errors-To:  message  header  overrides  the  error   return
   address.
   ...
-V envid
   Specify the envelope ID for notification by servers that support
   DSN.

 See RFC 3461 for more information about the envelope ID.

 Note that remote MTAs will report non-delivery or delays to the
 same sender address that you use for reporting remote SMTP server
 replies, though not all MTAs use the standardized format.

   Wietse

-- 
Michael Munger, dCAP, MCPS, MCNPS, MBSS
High Powered Help, Inc.
Microsoft Certified Professional
Microsoft Certified Small Business Specialist
Digium Certified Asterisk Professional
mich...@highpoweredhelp.com



Re: Capture / Filter Remote Server Responses?

2015-05-20 Thread Wietse Venema
Michael Munger:
 tldr:
 
 I want to be able to stick a filter / milter AFTER smtp(8) so I can
 save the remote server response code and associate it with an email
 that was sent so my PHP application can display the status of a
 notification sent to a user.

Postfix has an option to record SMTP remote server responses,
and to mail that back to the sender, formatted as a standard
internet delivery status notification.

You request this with /usr/sbin/sendmail -v recipient  See
http://www.postfix.org/ADDRESS_REWRITING_README.html#debugging
for an example and narrative text.

There currently is no option to request this in SMTP submissions.
This should be an access-restricted feature for obvious reasons.

Wietse