Witam,
tworzę właśnie stronę internetową i mam problem z formularzem kontaktowym. Gdy wysyłam formularz przekierowanie trwa bardzo długo i w efekcie nic się nie dzieje - zero błędów oraz brak wysłanego maila. Poniżej zamieszczam kod formularza i skrypt php.
KOD FORMULARZA
<form action="sendmail.php" method="post">
<input class="cntct" name="name" type="text" placeholder="Imię i nazwisko" />
<input class="cntct" name="name_c" type="text" placeholder="Imię dziecka" />
<input class="cntct" name="phone" type="tel" placeholder="Telefon kontaktowy" />
<input class="cntct" name="mail" type="email" placeholder="Adres e-mail" />
<textarea name="text" placeholder="Treść wiadomości"></textarea>
<input type="submit" name="submit" id="submit" value="Wyślij!" />
</form>
KOD PHP
<?php
require 'PHPMailerAutoload.php';
$name=strval($_POST['name']);
$name_c=strval($_POST['name_c']);
$tresc=strval($_POST['text']);
$telefon=strval($_POST['phone']);
$email=strval($_POST['mail']);
$mail = new PHPMailer;
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'serwer1628804.home.pl'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->CharSet = 'UTF-8';
$mail->setFrom('[email protected]', 'Formularz kontaktowy');
// $mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
// $mail->addReplyTo('[email protected]', 'Information');
// $mail->addCC('[email protected]');
// $mail->addBCC('[email protected]');
//
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Kontakt '.$name;
$mail->Body = '<h2>Kontakt: '.$name.'</h2><p>'.$tresc.'</p><ul><li>'.$name_c.'</li><li>'.$telefon.'</li><li>'.$email."</li></ul>";
if(!$mail->send()) {
echo 'Wiadomość nie mogła zostać przesłana Emotikon frown.';
echo 'Błąd: ' . $mail->ErrorInfo;
} else {
echo 'Wysłano Emotikon smile ';
}
?>