Skip to content

Instantly share code, notes, and snippets.

@Wockeez
Forked from sharkyak/mail.php
Created May 8, 2021 10:44
Show Gist options
  • Save Wockeez/92b54dd490e26dd1226dae69fcec0004 to your computer and use it in GitHub Desktop.
Save Wockeez/92b54dd490e26dd1226dae69fcec0004 to your computer and use it in GitHub Desktop.
axios vue mail post
<?php
$to = "[email protected]"; // адрес куда отправлять письмо
$subject = "Отправка формы с сайта"; // заголовок письма
$_POST = json_decode(file_get_contents('php://input'), true);
foreach($_POST as $key => $value)
{ $fields .= $key.": ".$value." \r\n"; }
$message = $subject." \r\n".$fields;
$headers = "Content-type: text/plain; charset=utf-8 \r\n";
mail($to, $subject, $message, $headers);
axios.post('mail.php', {
'Длина': this.length,
'Ширина': this.width
})
.then(function (response) {
alert('Благодарим за отправку обращения!')
})
.catch(function (error) {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment