I have a form which is used to send emails via PHP.
Now I had a user who said the email didn't go through. I checked, it appeared that only a name was saved in the field for the email address, not an email address.
So I added a client-side validation via regex which only allows you to send if the email has the format [text]@[text].[text] - common practice for validating email addresses.
The used regex:
var regex = /\S+@\S+\.\S+/;
Mustermann, Max <Max.Mustermann@gmail.com>
$email = "Mustermann, Max <Max.Mustermann@gmail.com>";
// prints out:
// string(42) "Mustermann, Max "
PHP does not cut anything off. but the
> are interpreted as HTML-tags and therefore omitted by your browser.
just look at the page source code and you will find your missing chars.
to see the whole text in HTML, you have to escape it: