# PHP: Validate Email Message

**URL:** https://forum.kirupa.com/t/php-validate-email-message/310815
**Category:** programming
**Created:** [June 20, 2010, 11:08am UTC](https://forum.kirupa.com/t/php-validate-email-message/310815 "2010-06-20T11:08:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![riveroaks](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@riveroaks](https://forum.kirupa.com/u/riveroaks)
#### Post date: [June 20, 2010, 11:08am UTC](https://forum.kirupa.com/t/php-validate-email-message/310815/1 "2010-06-20T11:08:07Z")

</div>

I’m putting together a simple contact form on my website. I have client and server side validation for the user’s name and e-mail address. But I was wondering, how should I go about validating the message?

From what I’ve read it seems just as easy to inject headers and malicious material into the body of the message, right? I know a common safeguard at least in the email value is to strip  
and \r, but I don’t want to destroy the new lines in the e-mail message.

Anyone know what kind of validation/corrections I should be making to the body of the message before I send it?

Thanks.
