Skip to content

Instantly share code, notes, and snippets.

@sharkyak
Created February 16, 2017 15:55
Show Gist options
  • Save sharkyak/850bc44120ba5b52421bb05b5e749d5f to your computer and use it in GitHub Desktop.
Save sharkyak/850bc44120ba5b52421bb05b5e749d5f 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