$value){ if (!empty($value)){ if(is_array($value)){ $value = implode(", ", $value); } $message_text .= ucwords($field) . "\n----------\n$value\n\n"; } } if(!mail($recipient, $email_subject, $message_text, $header)){ $error = "Unable to send mail. Check email address."; } } // here we output a message of success if the email was sent, or an error if we have any if ($error){ echo "
Error: $error
"; } else { echo "
Message sent. Thanks!
"; } } ?>