That's brilliant. I've added the following:
if (count($parts) == 2) {
$name = $parts[0];
$email = $parts[1];
} else {
$name = '';
$email = $parts[0];
}
I also came across a few more exceptions. For example, although this line is malformed, the script worked properly:
"Your new Swiss watch here. Lanny Hebert" <steed50
(all those spam messages by the way... 😉
So I'll need to do add more logic on my side to do something else when the email is malformed.
Also there was this sort of input:
Maxon@ip-208-109-122-158.ip.secureserver.net,
it is recognized as a valid email address, of course, but I need to make sure it does not contain any non-email characters on either side.