2015-07-11 16 views
5

Używam szablonu, ale mam problemy z wysyłaniem wiadomości e-mail za pomocą sendemail.php. Nie mogłem zrozumieć problemu. Oto kodyWyślij wiadomość e-mail za pomocą json'a

<?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; 

Oto część html kodów

<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> 

Proszę mi pomóc :-)

+0

Czy możesz podać błąd? –

+0

Nie daje żadnego błędu. W rzeczywistości jest napisane "wiadomość wysłana pomyślnie", ale po prostu nie wysyła wiadomości na podany adres. – bantandor

+0

Czy możesz usunąć @ na @mail? Ponieważ @ zignoruje cały błąd powiadomienia. –

Odpowiedz

0

Spróbuj użyć biblioteki elektronicznej, takich jak PHPMailer. Sendmail jest notorycznie niewiarygodny.

+0

to nie jest odpowiedź na pytanie OP. – HddnTHA

Powiązane problemy