I'm not a big fan of Event Sinks in Windows Server. If I can avoid establishing a sink I will do so at all costs.
Event Sinks, if you're not familiar w/ what they are, allow you to establish a script to run based on a raised event on the server. These are used most commonly w/ the SMTP_OnArrival event for processing received emails at time of receipt. This is sometimes an especially useful trick and I have implemented some fairly stable event sinks for this purpose. Years ago I had to write an entire email server from scratch! Without event sinks, this wouldn't be possible but I think programmers end up getting too wrapped up in event sinks for their purposes when real-time processing isn't necessary.
For the current project I'm working on, I need to process bounced emails to my server. My primary means of communicating w/ all the constituents of my website, including obviously registered users, is email. If an email address is failing, I need to know about it for 3 main reasons:
1.) You don't want to continue sending to invalid email addresses. Popular email providers will flag you for poor tactics like this and either delay or block your emails, once you have the bandwidth to appear on their radar.
2.) Depending on how you obtain email addresses and how often you distribute emails, at any given time a fraction of the email addresses in your database could be invalid. That fraction may be 1% or even larger but it exists. Imagine the bandwidth savings!
3.) Email is my primary means of contacting my constituents (users of different types that my website services). If an email address is invalid, I need to initiate a regular mailing, automated phone call, or manual phone call to the user to obtain a new and valid email address.
In this article, I plan on exhibiting how you can process bounced email messages and the related email address accordingly based on the message (hard bounce, soft bounce, and no action). All of this without having to worry w/ the tedious and seriously finnicky nature of event sinks, including re-starting your SMTP service for each change to your sink's rules.
All email received by your Windows server is directed towards a "Drop" folder. By default this folder is located at C:\inetpub\mailroot\drop\ but may be in a different place depending on your network administrator's preference (er, I mean personality). The A+ certification prep material actually teaches administrators that in order to be successful, they must learn to change every default setting to match their own personal style - this works to ensure job security and ensure continued salary inflation for their entire profession. This folder receives all email addressed to your server which is an important bit of information to know.
Instead of firing an event sink for real-time processing on arrival (indeed it sounds sexy) a much easier solution, and just as accomodating for most purposes, is to run an automated job that processes files in the Drop folder on a regular schedule (mine will be set at 1 hour but never on the actual hour - I'm superstitious).
I've included sample code that loops through the files in your Drop folder, parses the message to determine the bounce type, greps out the related email address, and performs some function on those matching email addresses in a database.
In all honesty, I wrote this code blind for this article since I'm not yet prepared to write it for my website project. I verified that the code executes, reads emails, flags appropriate terms, and doesn't include any syntax errors but I haven't verified much else that might occur in the real world (i.e. corrupt files) although I don't expect there would be any problems w/ it other than some error trapping. I don't need no stinkin' tests! The code isn't really the point of this article. You should grasp two important things from this article:
1.) Unique Concept - You CAN process bounced email messages without using Event Sinks! Scheduling a cron job is just as accomodating for nearly every purpose if you don't need to process your received email in real-time.
2.) Important Data - I've included a list of email terms at the bottom of this post that are categorized into 3 groups: Hard Bounces, Soft Bounces, No Action. Credit goes to a list I found from the following article though I had to do some scrubbing and de-duping:
http://www.aspfree.com/c/a/ASP-Code/An-easy-and-accurate-way-to-use-bounced-messages-to-clean-your-address-list/
The key is to loop through each list of terms, and exiting the function when a match is found for any term. If you want to error on the side of "no action" or "soft bounce", you might want to loop in reverse order from what is shown in my code.
I will be implementing the code I've written for this post in 4 - 6 weeks but I'm not yet at the right point in my project plan. If I make any siginificant tweaks during implementation or testing I will re-post the changes here. After initial deployment, I expect to make modifications and will post the changed code here w/ any lessons learned from real-world application.
Hard Bounces
----------------
cannot resolve
can't connect to host
this user doesn't have a
user unknown
unknown recipient
recipient unknown
not listed in public name
mailbox unavailable
account has been disabled
unrecognised recipient
the recipient name is not recognized
mailbox not found
mailbox inactive
invalid recipient
invalid address
invalid user
invactive user
destination addresses were unknown
user account inactive
no mailbox here by that name
unknown user
unknown or illegal alias
not known here
address not known
is not a valid maildrop
is not a valid user
addressee unknown
no such user
unsupported mail destination
no such host is known
non-existent host
unknown local part
550 command rcpt user
550 recipient
unknown host
user not found
recipient storage full
is unknown
a valid email address
user not known
unknown local-part
recipient user name not unique
no se encuentra en la libreta de direcciones
not listed in domino directory
retry time not reached for any host after a long failure period
user is not authorized to receive e-mail
mailbox has been suspended
account is disabled
mailbox disabled
carefully check that it was spelled correctly
not a valid mailbox
inactive user
does not exist
account discontinued
no such mailbox
mailbox name not allowed
error in recipient address
invalid mailbox
bad recipient
account expired
is inactive on this domain
mailbox is disabled
is no longer active
no user here by that name
no such address
doesn't exist
mailbox is inactive
550 mail refused
is now disabled with smtp service
user does not have an account
address rejected
connection timed out
post got bad listname
host not found
administrativley disabled
unable to connect
account not activated
not accepted
service not available
user not a member of domain
please check the spelling
non-local recipient
permanent delivery errors
incorrect domain
email-id does not exist
i have a new email
unknown virtual user
not a valid account
check if address is correct
address unknown
some addresses were rejected
not known at this site
account disable
i couldn't find any host named
address no longer accepts mail
destinataire n'est pas reconnu
account will be terminated
nicht im öffentlichem
adresse invalide
does not like recipient
not found in directory
email name is not found
host unknown
have stoped using my email account
no longer with us
recipient moved
destinataire inconnu
unknown local mailbox
nicht erkannt
can't find mailnode
556 conta inativa
invalid final delivery userid
unknown address
no such account
unbekannter empfänger
email address has changed
this address is not allowed
nicht im öffentlichen
non recense dans
closed due to inactivity
no such mail drop
user is no longer
computer could not be found
no such recipient
addresses below have changed
is not my user
this account is not
no se reconoce el recipiente
no account by that name
address is unrecognized
user has moved
delivery to the following recipients failed
attached is your mail message which could not be delivered
this email could not be delivered
this is a permanent error
usuario es inactivo
syntax error in address
user disabled
invalid email address
unrouteable address
email address is invalid
i seguenti indirizzi di destinazione risultano inesistenti
n'a pas ete distribue au destinataire
wurde nicht zugestellt
recapito non riuscito per i seguenti destinatari
+amk-chec de la remise aux destinataires suivants
error en la entrega a los siguientes destinatarios
error connecting to domain
is not available
your message has encountered delivery problems
Soft Bounces
---------------
over the allowed quota
quota violation
dns server could not be contacted
access denied
box full
box is full
exceeded storage allocation
that domain isn't in my list of allowed rcpthosts
insufficient disk space
message will exceed maximum mailbox size
user mailbox exceeds allowed size
user's disk quota exceeded
mailbox or conference is full
i/o error encountered
quota exceeded
this message has been in the queue too long
error while writing to dropfile
retry timeout exceeded
we do not accept mail from spammers
550 unknown
service unavailable
mail box space not enough
temporarily restricted from receiving email
over the storage quota
exceeded their disk quota
authentication required
out of quota
try again later
too many messages on the server
configured to reject your mail
temp failure; user is invited to retry
quota limit
server refused mail
too many letters during this connection
possible spam
exceed storage quota
over quota
i don't treat it as local
not local host hello
cannot route to
discarded by mail filter
helo command rejected
a restriction in the system prevented delivery of the message
local configuration error
mailbox_quota_exceeded
user blocked
not a gateway
relaying denied
local user only
mail loop
recipient ok
space shortage
exceeded dropfile size quota
this message is not welcome
maximum hop count exceeded
i no longer answer email
dns loop
has been blocked
recipient was unavailable
not accepting mail with attachments
new email address
mailbox voll
mailbox is temporarily suspended
recipient could not be processed
a loop was found
mail quota
550 relay
550 user
57 mail relay
relaying mail
pop3 before authentication
cannot relay
requested action aborted
56 sender
reached disk quota
exceeds allowed message count
message rejected due to content
this message is unwanted here
relay mail
relay request denied
too many connections
direccion electronica inexistente
remote sending only allowed with authentication
unresolvable relay
server too busy
content rejected
rejected by content
failed to open files for write
spam
create permissions on this folder
rejected for policy reasons
forced failure
configured to reject mail from
operation timed out
do not relay
space critically low
550 access to
rule imposed mailbox access
maximum allowed
exceeds mailbox storage
unrecoverable error
can't create output
over disk quota
too many hops
data format error
loops back to myself
name service error
der inhalt der nachricht ist zum ubermitteln zu lang
too much sessions in a connection
el mail no pudo ser entregado
was undeliverable to the following
undelivered message follows
échec de la remise aux destinataires suivants
relaying not allowed
disk full
your domain does not have access
the user name is invalid
unknown error
temporary local problem
please try later
connection not authorised
network is unreachable
server rejected
error_connection_broken
connection broken
dns_server_error
name server reports that it is having technical problems
No Action
-----------
non-fatal
this warning
will keep trying
out of the office
no action is required on your part
message delayed
delivery will be attempted for
i will be back
i am away
as soon as i return
this message has been forwarded
we will reply
received the email
received your email
message has been received
warning message only
reply to you
e-mail was received
has been forwarded to
on vacation
en vacances
no reply is necessary

Thanks for the great resource, I don't have a need for this now but am stashing it away in my code to use later bin.
Posted by: George Scott | Friday, April 18, 2008 at 05:14 PM