v2.5.2
Giriş yap

PHPMailer Contact Form Hatası

fethullahucar
785 defa görüntülendi

Merhabalar,
PHPMailer kullanarak contact form yapmaya çalışıyorum, mail geliyor fakat her yenilendiğinde boş mail geliyor.
Nasıl düzeltebilirim? Şimdiden teşekkürler...

Kodlarım:


<?php
require("class.phpmailer.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "mail.ucarweb.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->SetLanguage("tr", "phpmailer/language");
$mail->CharSet  ="utf-8";

$mail->Username = "[email protected]"; // Mail adresi
$mail->Password = "sifremgizlidir"; // Parola
$mail->SetFrom("[email protected]", "Siteden"); // Mail adresi

$mail->AddAddress("[email protected]"); // Gönderilecek kişi

$mail->Subject = "Siteden Gönderildi";
$mail->Body = <<<EOT
Email: {$_POST['email']}
Name: {$_POST['name']}
Message: {$_POST['message']}
EOT;
if (!$mail->send()) {
//The reason for failing to send will be in $mail->ErrorInfo
//but you shouldn't display errors to users - process the error, log it on your server.
$msg = 'Sorry, something went wrong. Please try again later.';
} else {
$msg = '<br><div><p>Your message has been sent. Thank you!</p></div>';
}
?>

	                                       <div class="contact_form">
	                                            <form method="post">
	                                                <input placeholder="Name" name="name" type="name" class="form-control">
	                                                <input placeholder="E-mail" name="email" type="email" class="form-control">
	                                                <textarea placeholder="Message" name="message" class="form-control"></textarea>
	                                                <button name="send" class="submit btn">Send Message</button>
													<?php if (!empty($msg)) {echo "<h2>$msg</h2>";} ?>

	                                                <!--Contact form message-->
	                                                <!--End contact form message-->
													
	                                            </form>
	                                        </div>
pcmemo
1600 gün önce

Üstteki kod bloklarına eğer send isimlie bir post geldiye anlamına gelen aşağıdaki kodları ekle. Ben ekliyorum.

<?php 
if (isset($_POST['send'])) { // kodların burdan aşağıdakiler
    
require("class.phpmailer.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "mail.ucarweb.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->SetLanguage("tr", "phpmailer/language");
$mail->CharSet  ="utf-8";

$mail->Username = "[email protected]"; // Mail adresi
$mail->Password = "sifremgizlidir"; // Parola
$mail->SetFrom("[email protected]", "Siteden"); // Mail adresi

$mail->AddAddress("[email protected]"); // Gönderilecek kişi

$mail->Subject = "Siteden Gönderildi";
$mail->Body = <<<EOT
Email: {$_POST['email']}
Name: {$_POST['name']}
Message: {$_POST['message']}
EOT;
if (!$mail->send()) {
//The reason for failing to send will be in $mail->ErrorInfo
//but you shouldn't display errors to users - process the error, log it on your server.
$msg = 'Sorry, something went wrong. Please try again later.';
} else {
$msg = '<br><div><p>Your message has been sent. Thank you!</p></div>';
}    

} // KOdların burdan yukarıdakiler


?>