If you don't trim the subject line like: $subject=trim($subject); You can wind up with the from field in the body of the message. If you are going to send email in the form: $to = "$toname <$toemail>"; make sure you strip commas and semicolons from $toname, otherwise mail() will think you are sending to more than one address. K, I was totally confused about the email validation code snippits from above. In my testing both were buggy. The following code seems to work perfectly well for the domains I listed below in the function calls. This includes hyphenated domains.
function checkmail ($email) {
	if (eregi("^[_\.0-9a-z-]+@([0-9a-z][-0-9a-z\.]+)\.([a-z]{2,3}$)", $email,
		$check)) {
		if (getmxrr($check[1].".".$check[2],$temp)) {
			return "Valid - ".$check[1].".".$check[2]."
			";
		}
		return "No MX for " . $check[1].".".$check[2]."
		";
	} else {
		return "Badly formed address.
		";
	}
}
echo checkmail("user@triple-bypass.com");
echo checkmail("user@salter.com");
echo checkmail("user@ns.sympatico.ca");
Be careful when sending results of a form/textarea when using mail(). If, for example, sendmail encounters a \n.\n (dot on it's own line) instance it will take this to mean the equivalent of an SMTP EOM command, and you'll end up with only half of your mail. In fact, it'd probably be better if the php.ini file came with "sendmail -ti" as default, instead. You could also use the function wordwrap(), to simplify this task, e.g.: $message = wordwrap($message, 75);