Results 1 to 2 of 2
Jun 2, 2009, 07:29 #1
SMTP Server Response Regular Expression
I am tryinng to put together some sort of regular expression to work with responses and codes.
Most responses begin with a 3 digit number such as 250, 550, etc.
on occasion we will receive a response not beginning with any number.
then most, not all contain an 3 digit error code separated by periods. Example 5.1.1, 5.0.4, etc.
I have three columns, Status Message (entire response message), Status Code (3 digit code), Error Code(3 digit with periods).
I am trying to generate a regular expression that might help me pull the status code and the error code out of the response message, and if either of them do not exisist the column would get a value of 0.
here is an example with both status and error code (note, status code and error code may not always be back to back as in this example):
"550 5.1.1 Invalid recipient: E3210 In response to the RCPT TO command"
Here is an exampl of a resonse with no status or error code:
"Name service error for chotmail.com Type=A: Host not found"
Thanks for the help.
Jun 11, 2009, 08:14 #2
- Join Date
- Apr 2009
- South Florida
- 0 Post(s)
- 0 Thread(s)
I am not sure which .Net language you are using, Here is a code snippet in C# to extract numeric values using regex
I would consider only keeping two columns and removing 3 digit with period. You can write a simple function to extract numbers (and merge them in to one number if its separated by period) and run the match.
Here is a small program which check for response header