<form action="yolla.php" method="post">
<label for="name">Ad:</label><br>
<input type="text" id="name" name="name"><br>
<label for="email">E-posta:</label><br>
<input type="text" id="email" name="email"><br>
<label for="phone">Telefon:</label><br>
<input type="text" id="phone" name="phone"><br>
<label for="message">Mesaj:</label><br>
<textarea id="message" name="message"></textarea><br>
<input type="submit" value="Gönder">
</form>
yolla.php
<?php
// Formdan gelen verileri topla
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Verileri doğrula (güvenlik amacıyla)
$name = strip_tags($name);
$name = htmlspecialchars($name);
$email = strip_tags($email);
$email = htmlspecialchars($email);
$phone = strip_tags($phone);
$phone = htmlspecialchars($phone);
$message = strip_tags($message);
$message = htmlspecialchars($message);
// Verileri e-posta ile göndermek için PHPMailer kullanın
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerException;
require 'path/to/PHPMailer/src/Exception.php';
require 'path/to/PHPMailer/src/PHPMailer.php';
require 'path/to/PHPMailer/src/SMTP.php';
$mail = new PHPMailer(true);
try {
// Sunucu ayarlarını yapılandırın
$mail->SMTPDebug = 0; // Hata ayıklama seviyesi: 1 = hata ve mesajlar, 2 = sadece mesajlar
$mail->isSMTP(); // SMTP kullanın
$mail->Host = 'smtp.example.com'; // SMTP sunucusunun adresi
$mail->SMTPAuth = true; // SMTP kimlik doğrulamasını etkinleştirin
$mail->Username = 'user@example.com'; // SMTP kullanıcı adı
$mail->Password = 'secret'; // SMTP parolası
$mail->SMTPSecure = 'tls'; // Güvenli bağlantı türü: tls veya ssl
$mail->Port = 587; // SMTP bağlantı noktası: 587 veya 465
// E-posta bilgilerini ayarlayın
$mail->setFrom($email, $name);
$mail->addAddress('recipient@example.com'); // Alıcı adresini ekleyin
$mail->addReplyTo($email, $name);
$mail->isHTML(true); // HTML e-posta olarak gönderin
$mail->Subject = 'Formdan Yeni Mesaj';
$mail->Body = $message;
$mail->AltBody = strip_tags($message);
$mail->send();
echo 'Mesajınız gönderildi!';
} catch (Exception $e) {
echo "Mesaj gönderilemedi: {$mail->ErrorInfo}";
}