我使用模板,但是使用sendemail.php发送电子邮件时遇到问题。我无法弄清楚这个问题。这是代码
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Mesajınız Gönderildi!'
);
$name = @trim(stripslashes($_POST['name']));
$email = @trim(stripslashes($_POST['email']));
//$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$email_from = $email;
$email_to = 'emailxxx@gmail.com';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
这是代码的html部分
<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="İsim">
</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="Mesajınız"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger btn-lg">Gönder</button>
</div>
</div>
</div>
</form>
请帮帮我: - )
答案 0 :(得分:0)
尝试使用PHPMailer等邮件库。众所周知,Sendmail是不可靠的。