Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Regex for VERP header
September 29, 2005, 8:13 pm
rate this thread
headers....the VERP header format is something like this:
If the return path is something @yahoo.com and the recipient email is
firstname.lastname@example.org , the verp address should be
The REGEX should be able to parse any VERP header....
Re: Regex for VERP header
I got some help from Carl Reynolds of http://hyperbole-software.com
here is the conversation:
I looked at the sendmail-hacks.txt for about five minutes. I don't want
to try to figure out what it's saying. It seems to start in the middle
of a conversation I did not hear the beginning of.
As far as creating a regular expression to handle the strings you want,
I know enough about regular expressions to try to advise you to create
Note that I have delimited all the regular expressions with slant-signs
(/). If your syntax doesn't require the expressions to be delimited,
copy the examples I have given without the slant-signs.
You are asking to create a regular expression to handle a string of the
Assuming there are no hyphens (-) in the 'something' part of of the
string let's start the pattern with
This says: match from the start of the string. Find anything that is
a hyphen one or more times. Followed by a hyphen. The "anything that is
not a hyphen" part gets put into a group to be used later. This will be
called group $1
Next we match the 'mynameisxyz' part of the string with
This is similar to the first pattern. It says Match anything that is
an equal sign one or more times and put that into a group called $2.
Then match the equal sign.
As far as matching the e-mail address, if you are trying to match any
e-mail address, it needs to conform to RFC 822
<http://www.ietf.org/rfc/rfc0822.txt - <quote>which is filled with
impenetrable discussions on "sequences of lexical symbols" such as
"atoms", "special characters", "domain-literals" and
Over the last couple of weeks I have read a number of articles on
matching e-mail addresses with regular expressions and they all agree
that there is no way to match all the addresses specified by RFC 822
with a single regular expression.
However, if you can restrict the addresses you want to match to a known
subset of RFC 822, there is hope you can match all of that subset.
Here is an expression that seems to match a very large subset of e-mail
addresses. It comes from
He claims to match every possible e-mail address, but that claim is not
Now we have three expressions to match the individual parts of your
string. Let's put them together to create one monster expression to
parse the entire line
You will need to test this line against the e-mails you want to pass
through your VERP filter and see if it will do what you want.
You said you are willing to restrict the e-mail addresses to the form
In that case use
However, keep in mind that this is a very small subset of the valid
e-mail addresses allowed on the net.
This gives you a place to start figuring out what does and what doesn't
- Klaus Alexander Seistrup
October 5, 2005, 6:05 am
Re: Regex for VERP header
The Perl Mail::RFC822::Address claims to be able to parse RFC 822 addresses,
and if you read the specs I believe it is true (hint: look at how the regexp
is being built in the Perl source, and refer to RFC 2822).
The monstrous regexp can be seen at
Klaus Alexander Seistrup
PNX · http://pnx.dk /
- » Linux just shutdown at exactly 1:30pm for no reason... please help!
- — Next thread in » Linux Security
- » Cloud Ace Technologies is offering Implementation Services on Cloud Computing, Cloud Serv...
- — Newest thread in » Linux Security