2015-07-11 21 views
5

我使用模板,但使用sendemail.php發送電子郵件時遇到問題。我無法弄清楚問題所在。下面是代碼使用json的Sendemail

<?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 = '[email protected]'; 

$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

它不會給出任何錯誤。實際上它說「消息發送成功」,但不發送電子郵件到指定的地址。 – bantandor

+0

你可以在@mail上刪除@嗎?因爲@會忽略所有通知錯誤。 –

回答

0

使用郵件庫,如PHPMailer的嘗試。 Sendmail是臭名昭着的不可靠的。

+0

這不是OP的問題的答案。 – HddnTHA