I am trying to design a messaging center for the admin of my site. Basically all they have a is a subject and message line. Then I send those through AJAX to my php file where I set the subject and message variables to what I sent over. My question is how can I write a message where it recognizes breaks in between lines by hitting the enter key or where I can add in a link without having to do
<a href="google.com">Google</a>
My form is very basic.
<form action="" method="post" id="rating_form">
<input type="text" class="inputbar" name="subject" placeholder="Subject" required>
<textarea rows="8" cols="50" name="message" class="inputbarmessage" placeholder="Message" required></textarea>
<label for="contactButton">
<input type="button" class="contactButton" value="Send Message" id="submit">
</label>
</form>
As is my email...
$to = '';
while ($stmt->fetch()) {
$to .= $user_email . ', ';
}
$from = "surveys@example.com";
$Bcc = "surveys_check@example.com";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: ' .$from. "\r\n";
$headers .= 'Bcc: '.$Bcc. "\r\n";
if (!empty($user_email)) {
if (filter_var($user_email, FILTER_VALIDATE_EMAIL)) {
//Should also do a check on the mail function
if (mail($to, $subject, $message, $headers)) {
echo "Your email was sent!"; // success message
} else {
echo "Mail could not be sent!"; // failed message
}
} else {
//Invalid email
echo "Invalid Email, please provide a valid email address.";
}
} else {
echo "Email Address was not filled out.";
}
I really want a way to do this because no one else knows code and that would be a pain for them. I just want them to be able to type simple messages and send.
Thanks!
`. http://php.net/manual/en/function.nl2br.php – chris85 Sep 17 '15 at 15:26
` which a browser/mail client will read as a new line.. – chris85 Sep 17 '15 at 15:33