i try to send a mail with php and axios. i store my data on some properties and then try to call a post method via axios. EMAIL WITH BE SENT but with empty values. looks like i cannot get this values in php.
// js
axios
.post("./vendor/sendmail.php", {
name: nameInput.value,
email: emailInput.value,
message: textarea.value
})
.then(respond => {
console.log(respond);
})
.catch(error => {
console.log(error);
});
// php
<?php
$email = $_POST['email'];
$message = $_POST['message'];
$name = $_POST['name'];
$body = "Email: {$email}\n\nName: {$name}\n\nMessage: {$message}\n\n";
mail("myemail@gmail.com", 'A new message', $body, "From: test@gmail.com");
?>
i get this in my inbox:
Email:
Name:
Message:
(an email with empty values)