procmail
[Top] [All Lists]

Re: extracting the "from" and "Subject" headings and writing them to a log

2000-09-11 20:57:23
At 11:44 2000-09-11 -0600, LOPEZ,ERWIN (HP-Cupertino,ex1) wrote:
I want to be able to extract the "from" and "subject" headings from emails

the subject of the bounce itself, or of the message which bounced? The first is easy:

:0
* ^Subject:\/.*
{
        SUBJECT=$MATCH
}

This is going to result in something like "Undeliverable Mail", "Returned Mail: cause" (where cause is "service unknown" "user unknown" "see transcript for detauls", etc). There are an abundance of other subjects on bounce messages. I can't recall in recent history having received a bounce which had the original message subject anywhere in the bounce subject.

Now, if you're hoping to get the message subject from the body, you can't assume it will exist in the body (bounce messages unfortunatley being so VERY nonstandard), and line continuation won't take place automatically as it does with headers (since the original Subject, if included at all, will be in the BODY).

:0b
* ^[    \>]*Subject:\/.*
{
        SUBJECT=$MATCH
}

Would likely find the first subject embedded in the body of a message (which may possibly be indented or quoted).

that bounce and store them into a file.  So for example if I send an email
to erwin(_at_)hotmail(_dot_)com with subject heading "hello there".  If the 
email comes

A LIST message, including the distribution to erwin, or a message directly addressed to him?

The way mailing lists are starting to do this (though with a DRAMATIC increase in server mail delivery load), is to send out copies of the list message to each individual subscriber, using a specific return path. A plussed addres might work here, though they typically are using a sendmail virtusertable entry or the like to generate a wildcard email address, then either include a listname+escaped subscriber address, or listname+hashed subscriber address (a hashed code representing the lookup index for the subscriber). This way, when a message bounces, the address is comes back to on the listserv identifies where it was originally addressed to -- nobody but that subscriber or their mail system would be replying to the given address. In addition, it insures that you won't get a cryptic bounce talking about delivery problems to half a dozen addresses other than the user you were delivering it to (deferred deliveries and server connection timeouts, etc). Another benefit is that this helps identify who the subscriber was on your list when the bounce is resulting from an n-th generation forward or mail alias (i.e. IF it mentions an email address, you might not even be able to find it in your subscribership anyway).

You'll still run into problems with braindead MTAs that insist on sending errors to the from or reply-to addresses and the like (a big problem on mailing lists - the listserv often doesn't see these bounces because the braindead MTA of the subscriber is redirecting them to the author of the message - who hasn't a CLUE as to who is subscribed to the list, and can't do anything about it anyway). Corporate MTA (like Lotus mail/cc:notes, and several apps that run on Windows NT in an attempt to provide mail services) seem to be the biggest offenders here.

bounces and comes I want to be able to extract "erwin(_at_)hotmail(_dot_)com" an 
"hello
there" and store it into a file without the server name it bounced from and

As I mentioned earlier, getting a bounce message that identifies these elements in a consistent fashion will be a task. Have fun.


Personally, I just route all postmaster messages into a mailbox (right near the top of all my filtering, which allows me to skip looking for FROM_DAEMON, etc. in each rule), and just check that directly. There's too much manual intervention required on some bounces.

---
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

 Sean B. Straw / Professional Software Engineering
 Post Box 2395 / San Rafael, CA  94912-2395


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>