Witam! Stworzyłam formularz kontaktowy, którego zawartość pól ma zostać wysłana na konkretny adres email. Niestety nie potrafię go uruchomić - przeglądarka ciągle wyrzuca mi taki błąd: E-mail nie mógł zostać wysłany, przyczyna :You must provide at least one recipient email address. error_reporting(E_ALL); ini_set('display_errors','1'); Kod formularza poniżej a ustawienia phpmailera w class phpmailer.php, którego zawartośc wkleiłam tutaj
tutaj - nie miałam wyjścia, forum wyrzucalo komunikat, że post za długi. Bardzo proszę o pomoc
Formularz
<?php
require_once('class.phpmailer.php'); //dodanie klasy phpmailer
require_once('class.smtp.php');
mysql_query("SET NAMES `utf8` COLLATE `utf8_polish_ci`"); //display contact
$q6 = "SELECT contactinfo FROM admin WHERE id=1";
$mail = new PHPMailer();
if(isset($_POST['send'])){
//$email_to= ('solaris_ustronie@o2');
$mail->AddAddress= ('solaris_ustronie@o2');
$email_subject = "Zapytanie rezerwacyjne z formularza kontaktowego";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; }
// validation expected data exists
/* if(!isset($_POST['name']) ||
!isset($_POST['telefon'])||
!isset($_POST['email'])) ||
!isset($_POST['tytul'])) ||
!isset($_POST['tresc'])){
died('We are sorry, but there appears to be a problem with the form you submitted.');
}*/
$uname = $_POST['name']; // required
$tel = $_POST['telefon']; // required
$email_from = $_POST['email']; // required
$tytul = $_POST['tytul'];
$tresc = $_POST['tresc']; // required
/* $error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'Niepoprawny adres Email .<br />';
}*/
/*$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$username)) {
$error_message .= 'The Username you entered does not appear to be valid.<br />';
}*/
if (empty($_POST["email_from"])) { $emailErr = "Email wymagany";
} else {
// $email = test_input($_POST["email_from"]);
// check if e-mail address is well-formed
if (!filter_var($email_from, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Niepoprawny adres email";
}
}
if (empty($_POST["tel"])) { $telErr = "Telefon wymagany";
}
$telErr = "Dozwolone tylko cyfry";
}
if((strlen($_POST["tel"]))<9
){ $telErr = "Musi zawierać min 9 cyfr";
}
if (empty($_POST["name"])) { $nameErr = "Imię i nazwisko wymagane";
} else {
// $name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
$nameErr = "Dozwolone tylko litery";
}
}
if (empty($_POST["tresc"])) { $comment = "Treść wiaoomości wymagana";
} /*else {
$comment = test_input($_POST["tresc"]);
}*/
if(strlen($error_message) > 0
) { died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href"); }
$email_message .= "Imię i nazwisko: ".clean_string($name)."\n";
$email_message .= "Telefon: ".clean_string($tel)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Tytuł wiadomości: ".clean_string($tytul)."\n";
$email_message .= "Treść wiadomości: ".clean_string($tresc)."\n";
$email_message .= "AddReplyTo: ".clean_string('$email_from','$name')."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
@mail($email_to, $email_subject, $tytul, $email_message, $headers); }
if($mail->Send())
{
echo $confirm = "<b style='color:green'>Wiadomość została wysłana</b>"; }
else
{
echo 'E-mail nie mógł zostać wysłany, przyczyna :'. $mail->ErrorInfo; }
$mail->ClearAddresses();
$mail->ClearAttachments();
//Redirect to Thank You HTML page after email is sent
?>
error_reporting(E_ALL);
ini_set('display_errors','1');
<table width="988" height="693" border="0" colspan="2"> <td width="988" height="34" style=" position: absolute; top: 598px; left: 285px;" border="1"><center> <p><b><?php while($contactdisp = mysql_fetch_array($q61)){echo $contactdisp['contactinfo'];} ?></p> <th height="626" bgcolor=""> <fieldset style="display:inline-flex; height: 550px; width: 560px; color:191B7E; position:absolute; top:740px; left:500px;"><legend ><font size="+2">Formularz Kontaktowy
</font></legend> <div style ="position: absolute; top: 35px; left:125px; slign:center;"><p>Pola oznaczone symbolem * są wymagane
<p></br> </br><p><font size="+1"> *Imię i nazwisko :
</font><input type="text" name="name" placeholder=" Podaj swoje imię i nazwisko" style="height:30px; width:250px; "></br> </br><p><font size="+1"> *Telefon :
</font><input type="tel" name="telefon" placeholder="Podaj swój numer telefonu" style="height:30px; width:250px;"maxlength = "15"></br> </br><p><font size="+1"> *Email :
</font><input type="email" name="email" placeholder="Podaj swój adres email" style="height:30px; width:250px;"></p> </br><p><font size="+1"> Tytuł wiadomości :
</font><input type="text" name="tytul" placeholder="Podaj tytuł wiadomości" style="height:30px; width:250px;"></p> </br><p><font size="+1">*Treść wiadomości :
</font><input type="text" name="tresc" placeholder="Podaj treść wiadomości" style="height:150px; width:250px;"></p></div> <div style="position: absolute; top: 480px; left:305px;"><p><input type="submit" value="Wyślij" name="send"> <input type="reset" value="Wyczyść"></p></div></fieldset>