in reply to Matching multiple patterns with regex

don't have to add much, but if it's a "standard compliant" mail message:
RFC 2822 seems to state the "Subject:" and other keywords are case-INsensitive, so you should match /From:/i and /Subject:/i, respectively.
Email::Simple, as recommended by Athanasius, does already provide for this and other tiny quirks.

Replies are listed 'Best First'.
Re^2: Matching multiple patterns with regex
by afoken (Chancellor) on Oct 31, 2015 at 12:15 UTC
    RFC 2822 seems to state the "Subject:" and other keywords are case-INsensitive

    ... and to make things worse, "2.2.3. Long Header Fields" allows to wrap lines so that the content is split over several lines. This is a single logical header line, split over several physical lines:

    Subject: Mail parsing looks simple until you have read the RFCs

    Additionally, RFC2047 allows encoding of non-ASCII characters.

    Any mail parser should be able to handle that, too.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)