Php Smtp ile mail gönderimi


Aşagıdaki kodları kullanarak iletişim form larınızdaki bütün inputların içeriğini mail adresinize güvenli şekilde gönderebilirsiniz.


form.php olarak kaydedin.

<!doctype html>
<html lang="en">
<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
  <title>İletişim Formu</title>
</head>
<body>
  <div class="container"> 
    <br>  
    <h3> İletişim Formu</h3>
    <div  class="col-md-6 bg-info form-group"> 
      <form action="" method="POST">
        <div class="row">
          <div class="col-md-6">
            <label>İsim</label>
            <input class="form-control" type="text" maxlength="25" name="isim" required="">
          </div>
          <div class="col-md-6">
           <label>Soyisim</label>
           <input class="form-control" type="text" name="soyad" required=""> 
         </div>
       </div>  
       <label>E-Mail</label>
       <input class="form-control" type="email" name="email" required="">
       <label>Telefon</label>
       <input class="form-control" type="number" name="tel" required="">
       <label>Doğum Tarihi</label>
       <input class="form-control" type="date" name="dt" required="">
       <input class="form-control" type="text" value="Doğum tarihi zorunludur." disabled="" name="email">
       <label>Hizmetler</label>
       <select name="hizmetler" class="form-control"> 
         <option>web tasarım</option>
         <option>html kodlama</option>
         <option>teknik servis</option>
       </select>
       <label>Açıklama</label>
       <textarea class="form-control" name="aciklama" type="text"> </textarea>
       <br>  
       <button class="btn btn-success"  name="gonder" type="submit">Gönder</button>
       <button class="btn btn-danger" name="temizle" type="button">Temizle</button>
     </form>
   </div>
 </div>
 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
</body>
</html>

gonder.php olarak kaydedin.

<meta http-equiv="refresh" content="2;URL= iletisim-formu.html">

<?
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();                                   // send via SMTP
$mail->Host     = "mail.vuralcomputer.com"; // SMTP servers
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "deneme@vuralcomputer.com";  // SMTP username
$mail->Password = "1123123123"; // SMTP password
$mail->CharSet = 'UTF-8';
$mail->Port = 587;
$mail->From     = "deneme@vuralcomputer.com"; // smtp kullanycy adynyz ile ayny olmaly
$mail->Fromname = "giden ismi";
$mail->AddAddress("vural@vuralcomputer.com","Websitenizden gelen Sipariþiniz.");
$mail->Subject  =  $_POST['isim'];
$mail->IsHTML(true);
$mail->Body = '<table>
        <tr>
            <td style="border:1px solid #ddd;padding:5px">Adı Soyadı</td>
            <td style="border:1px solid #ddd;padding:5px">'.urldecode($_POST['isim'].''.$_POST['soyad']).'</td>
        </tr>

        <tr>
            <td style="border:1px solid #ddd;padding:5px">Başlık</td>
            <td style="border:1px solid #ddd;padding:5px">'.urldecode($_POST['email']).'</td>
        </tr>

        <tr>
            <td style="border:1px solid #ddd;padding:5px">İçerik</td>
            <td style="border:1px solid #ddd;padding:5px">'.urldecode($_POST['tel']).'</td>
        </tr>
    </table>';

if(!$mail->Send())
{
   echo "Mesaj Gönderilemedi <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo '<script type="text/javascript">alert("E Postanız  Başarı ile  Gönderilmiştir.");</script>';

?>