Hi im new to PHP and i'am having issues sending an email. Im getting the following message when i trigger the funtion with axios:
Access to XMLHttpRequest at 'myServer/EinladungMail.php' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
quasar.esm.js?b178:6 POST myServer/EinladungMail.php net::ERR_FAILED
my php code:
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT');
header('Access-Control-Allow-Headers: Content-Type');
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
$mail = $_POST["mail"];
$message= 'myMessage';
$headers = 'From: noreply@company.com';
$mail($mail, 'Einladung', $message, $headers );
JS:
if (this.ValidateEmail()) {
axios({
method: 'post',
url: 'myserver/EinladungMail.php',
data: {
mail: this.mail2
}
}).then(response => {
console.log(response)
window.alert('einladung gesendet')
}
).catch(
error => {
window.alert(error.message)
}
)
}
thanks in advance