Answer the question
In order to leave comments, you need to log in
Sendmail script not working correctly?
There is a problem with the sendmail script, mail is sent without problems, but forwarded fields like Name E-mail and Message text are empty.
Script code
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Письмо отправлено!'
);
$name = @trim(stripslashes($_POST['name']));
$email = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$email_from = '****@***.***';
$email_to = '*********@gmail.com';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php" role="form">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="form-control" required="required" placeholder="Ваше имя">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="form-control" required="required" placeholder="Ваш Email">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<textarea name="message" id="message" required="required" class="form-control" rows="8" placeholder="Ваше сообщение"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger btn-lg">Отправить</button>
</div>
</div>
</div>
</form>
Answer the question
In order to leave comments, you need to log in
<input type="text" class="form-control" required="required" placeholder="Ваше имя">
<input type="text" class="form-control" required="required" placeholder="Ваш Email">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question