Hi I need to read in an email (source with header), and extract the sender's name, or his email address if the name is not available. For example, these are possible "From: " lines in email headers:
From: abc@abc.com
From: <abc@abc.com>
From: ABC <abc@abc.com>
From: "ABC" <abc@abc.com>
For case 1 and 2, I need to extract the email address (since the name is not available), so it should return me abc@abc.com.
For case 3 and 4, I need to extract the name ABC.
Can anyone show me how to do this in Perl? I am really no good in regular expression and hope that you can help...
Start Free Trial