联系脚本不起作用

时间:2016-02-25 20:19:46

标签: php forms contact

我正在创建我的网站,我的联系表单有问题。我在PHP中找到了联系脚本,我尝试配置它。当我发送表单时,页面加载了很长时间,然后什么都没发生 - 邮件没有发送,也没有显示任何错误。你有什么建议吗?在我的代码下面

<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>

<?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 = 'kontakt@yyy.pl';                 // 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('kontakt@yyy.pl', 'Formularz kontaktowy');
// $mail->addAddress('kontakt@yyy..pl', 'Joe User');     // Add a recipient
$mail->addAddress('kontakt.p@gmail.com');               // Name is optional

// $mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
//
// $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 ';
}

?>

0 个答案:

没有答案
相关问题