2015-07-31 4 views
0

Я хочу, чтобы сделать 1 простую программу, которая может отправку почты на мою почту так что мой код программы я пытаюсь запустить его в домене и хостинге , но я получил сообщение об ошибке 404PHP Ошибка почтовой программы 404 неверный код

здесь является index.php не полный, только некоторые из кода

<section> 
    <div class="container"> 
    <div class="ac"> 
          <form action=’mail.php’ method=’post’> 
         <ul> 
          <li>Email :</li><input type="text" placeholder="Your Email Address" name='email'/> 
          <li>Name :</li><input type="text" placeholder="Your Name" name='nama' /> 

          <li><h1>Your Request   :<br> <textarea placeholder="Type your request here!" style="width: 800px; height: 150px;" name='comment' id='comment'></textarea> <br> 
          </li></h1> 


          <button type="submit" >Submit <i class="fa fa-arrow-circle-o-right"></i></button> 
         </ul></form> 

    </div>   
    </div> 
</section 

и это mail.php

 <?php 
    require_once("class.phpmailer.php"); 
    $sendmail = new PHPMailer(); 

$email=$_POST[‘email’]; 
$nama=$_POST[’nama’]; 
$comment=$_POST[‘comment’]; 


    $sendmail->setFrom($email); //email pengirim 
    $sendmail->addReplyTo($email); //email replay 
    $sendmail->addAddress('[email protected]','Steven'); //email tujuan 
    $sendmail->Subject = $nama; //subjek email 
    $sendmail->Body=$comment ; //isi pesan 
    $sendmail->isHTML(true); 
    if(!$sendmail->Send()) 
    { 
     echo "Email Sended Fail : " . $sendmail->ErrorInfo; 
    } 
    else 
    { 
     echo "Email Sended Succesfuly!"; 
    } 
?> 

мольбы se помочь мне исправить, я не могу найти решение

+1

Вам необходимо подключиться к SMTP-серверу Gmail, а затем проверку подлинности, а затем отправить по электронной почте. – kkaosninja

ответ

0

Ниже приведен небольшой фрагмент PHPMailer, который я обычно использую. Надеюсь, вы найдете ее полезной.

function sendMail($toAddress, $subject, $body, $AttachmentFilePath) { 
$mail = new PHPMailer(); 

$mail->IsSMTP(); 
$mail->CharSet = 'UTF-8'; 
// nable SMTP debugging 
// 0 = off (for production use) 
// 1 = client messages 
// 2 = client and server messages 
$mail->SMTPDebug = 0; // To prevent any outpur 
// Ask for HTML-friendly debug output 
$mail->Debugoutput = 'html'; 
// Get the hostname of the mail server 
$mail->Host = 'smtp.gmail.com'; 
// Get the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission 
$mail->Port = 587; 
// Get the encryption system to use - ssl (deprecated) or tls 
$mail->SMTPSecure = 'tls'; 
// Whether to use SMTP authentication 
$mail->SMTPAuth = TRUE; 

// Username to use for SMTP authentication - use full email address for gmail 
$mail->Username = "[email protected]"; 
// Password to use for SMTP authentication. Specific to the Lead Qualifier Tool 
$mail->Password = "YourPassWordHere"; 

// Set who the message is to be sent from 
$mail->SetFrom ('[email protected]', 'Your Name'); 

// To Address 
$mail->AddAddress ($toAddress, $toAddress); 

$mail->Subject = $subject; 

$mail->Body = $body; 
$mail->AltBody = $body; 

// Add attachment 
if ($AttachmentFilePath != NULL) 
    $mail->AddAttachment ($AttachmentFilePath); 

if (! $mail->Send()) { 
    echo "<br />Error while sending e-mail: " . $mail->ErrorInfo; 
} else { 
    // echo "Message sent!"; 
} 
} 

Кроме того, так как вы используете Gmail, убедитесь, что вы создаете ASP (Application Specific Password), и использовать его в коде, а не ваш реальный пароль.

+0

благодарю вас за ваш код, но это похоже на то, что я начинаю с нового, может, вы просто исправляете мой код вверх? –

0

A 404 ошибка указывает, что страница не найдена. Я подозреваю, что это связано с фигурными одинарные кавычки в вашем <form> элемент

<form action=’mail.php’ method=’post’> 
      ^ ^ ^^

изменить это на

<form action='mail.php' method='post'>