If you intend to write an RFC822 parser, please, please take the advice of everyone who has done so until now: Do not write a parser which accepts only what is specified in RFC822 exactly and nothing else. Rather, write a parser which accepts and tries to understand everything which remotely looks like RFC822! Otherwise you will get into endless trouble. Example of illegal RFC822 things you should accept: John Smith <JS@HOST> should correctly be "John Smith" <JS@HOST> Message-ID: <AAA&BBB@CCC> should correctly be Message-ID: <"AAA6BBB"@CCC> Message-ID: <AAA@BBB> (From my perfect mailer) should correctly be Message-ID: <AAA@BBB> etc. etc. And please do accept things, even if they are on different lines. Thus you should accept: To: "a very very very very very very very very very long name" <AAA@BBB> Even though the name is split on several lines. I could give you unlimited more examples.