procmail
[Top] [All Lists]

RE: get email address from the body of the email

2007-05-15 10:00:17
At 09:06 2007-05-15 -0400, Alex Kosach wrote:
The email type I am talking about is a bounceback email. Unfortunately,
these emails do not have any common structure and there is no common
place where you can find email address in the email body. Also, some of
these emails are plain text but some are encoded. The only common thing
about these emails is who sends them. They all come from MAILER-DAEMONs

Sometimes they won't.  Especially when dealing with A/V scanners.

Some other things to note about bounces:

Many MS-exchange configurations will identify only an internal email 
identifier - sometimes not even an RFC822 address, just a username portion, 
which itself isn't part of the address you actually sent mail to.

If the mail passes through a forwarding service, and THEN is bounced, if 
you're fortunate enough to retrieve an email address from the body of the 
message, if very well may not be the address which you sent mail to, but 
the endpoint address.  This is the bane of list administrators, who can't 
find that address in their user list.  Some systems don't bounce complete 
headers, so you don't have record of where the message was forwarded through.


If this is for handling a list, rather than try to parse the message, try 
modifying how you're sending them - use a different envelope sender for 
each message and use THAT to identify the recipient.  When a message 
bounces, the address which the bounce is sent to will identify the user.

If sending on behalf of somelist(_at_)yourdomain(_dot_)tld, to a user 
emailaddress(_at_)host(_dot_)domain(_dot_)tld, your envelope address might be:

somelist-return+emailaddress=host(_dot_)domain(_dot_)tld(_at_)yourdomain(_dot_)tld

Note the users original @ is replaced with an =, and that the message is 
using "plussed" addressing.  This is easy to set up on sendmail, and the 
"somelist-return" is the only address which needs to be configured in 
sendmail to direct messages to a procmail script to handle them, which can 
then take the recipient address (generally the To:, or the envelope-to, if 
you're got your MTA configured to add that header), and parse out the 
original message recipient.

IIRC something every similar is integral to QMail and some list management 
software whose name escapes me at the moment.

Besides the MTA-specific configuration you need to do to set this up, there 
is a downside: your message deliveries need to be user-unique.  That is, 
you don't send ONE message BCC to 1,000 recipients - you send 1,000 
messages each with a separate envelope-from address (but which are 
otherwise all identical).  If you have a list where you're sending out 
messages once in a while, but with large attachments, and say, you have 
scores of users at the same ISPs, plus of course lots of users at loner 
ISPs, then those groups of users at the same ISPs would only entail a 
SINGLE network transfer of your large message with attachment, whereas the 
modified method would involve individual deliveries for EACH recipient at 
that ISP.  If you have a large discussion list with frequent traffic, you 
could go from a mail queue of a few hundred messages on a busy day, to one 
with 10,000+ messages (and the requisite storage for the individual copies 
of messages in the queue).


There's another technique - send list messages normally (batched, BCC), and 
once a month, send out a special one-per-recipient (with recipient-specific 
envelope-sender) "feeler" message, from which you process bounces.  MailMan 
does this (or rather, can be configured to).

---
  Sean B. Straw / Professional Software Engineering

  Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
  Please DO NOT carbon me on list replies.  I'll get my copy from the list.


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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