Arkadaşlar merhaba,
phpmailer fonksiyonu sorunsuz çalışıyor, sadece recaptcha ile phpmail komutlarını nasıl birleştirebilirim, yani recaptcha doğru girildiği zaman phpmailer çalışacak ve maili gönderecek.
if ($_POST) {
$secretKey = "6LdV5AITAAAAAOwG3lVIjKHklZg8wELGUlXRbuYR";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
if(isset($_POST['ad']) && isset($_POST['eposta']) && isset($_POST['konu']) && isset($_POST['mesaj']) && isset($_POST['g-recaptcha-response'])) {
function epostakontrol($email){if (filter_var($email, FILTER_VALIDATE_EMAIL)){return 1;} else {return 0;}}
$gelen_mail = $_POST['eposta']; $mail_kontol=epostakontrol($gelen_mail);
if(empty($_POST['ad']) || empty($_POST['eposta']) || empty($_POST['konu']) || empty($_POST['mesaj'])) {
echo '<h5>Lütfen boş yer bırakmayın.</h5>';
} else if($mail_kontol == "0"){echo '<h5>Lütfen e-posta adresini doğru girin.</h5>';} else{
include 'PHPMailerAutoload.php';
$phpmailer = new PHPMailer;
$phpmailer->isSMTP();
$phpmailer->Host = 'mail.mail.com.tr';
$phpmailer->SMTPAuth = true;
$phpmailer->Username = 'eposta@eposta.com';
$phpmailer->Password = 'şifre';
$phpmailer->SMTPSecure = 'tls';
$phpmailer->Port = '587';
$phpmailer->From = 'eposta@eposta.com';
$phpmailer->FromName = 'Iletisim Formu';
$phpmailer->AddReplyTo($_POST['ad'], $_POST['eposta'], $_POST['tel'], $_POST['konu']);
$phpmailer->addAddress('eposta@eposta.com', 'Iletisim Formu');
$phpmailer->Subject = $_POST['konu'];
$phpmailer->isHTML(true);
$ad = $_POST['ad'];
$eposta = $_POST['eposta'];
$tel = $_POST['tel'];
$konu = $_POST['konu'];
$mesaj = $_POST['mesaj'];
$msg=$msg.'<h3>Ad Soyad : </h3>'.$ad."<br />";
$msg=$msg.'<h3>E-Mail : </h3>'.$eposta."<br />";
$msg=$msg.'<h3>Telefon : </h3>'.$tel."<br />";
$msg=$msg.'<h3>Konu : </h3>'.$konu."<br />";
$msg=$msg.'<h3>Mesaj : </h3>'.$mesaj."\n";
$body = $msg;
$phpmailer->CharSet = 'iso-8859-1';
$phpmailer->MsgHTML($body);
if($phpmailer->Send()) { echo '<h5>Mesajınız başarıyla gönderildi.</h5>';}
else { echo '<h5>Mesaj gönderirken bir hata oluştu ve girmiş olduğunuz bilgiler alınamadı.</h5>' . $phpmailer->ErrorInfo;}
}
}
}
}