I have a rather simple HTML/PHP form that just needs to send the data to my email. The email I'm using is not using the same domain as the website. I've been stuck on this for hours now and I cant seem to find the solution. Could someone take a look?
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$message = $_POST['message'];
$gender = $_POST['gender'];
$user_name = $_POST['user_name'];
$email = $_POST['email"];
$message = $_POST['message'];
$from = $_POST['user_name'];
$to = 'example@email.com';
$subject = 'Comment';
$body = "From: $first_name\n From: $last_name\n Sex: $gender\n Username: $user_name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo 'Your message has been sent!';
} else {
echo 'Something went wrong, go back and try again!';
}
}
?>