Kod: Zaznacz cały
<form class="forms" action="contact/form-handler.php" method="post">
<div class="form-group">
<div class="col-sm-4" style="position:relative">
<input type="text" name="name" class="form-control label_better" placeholder="Imię i Nazwisko:" required>
</div>
<div class="col-sm-4">
<input type="text" name="email" class="form-control label_better" placeholder="E-mail" required>
</div>
<div class="col-sm-4">
<input type="text" name="Phone" class="form-control label_better" placeholder="Telefon kontaktowy:" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<textarea type="text" name="message" class="form-control label_better" placeholder="Wiadomość:" rows="7" required></textarea>
</div>
</div>
<div class="form-group commands">
<button class="btn btn-primary">Wyślij wiadomość</button>
</div>
</form>
w contact mam pliki :
form.html
form-handler.php
SMTPClass.php
Kod: Zaznacz cały
plik form-handler.php wygląda tak ( pokazuje go bo index html ma go zawartego):
<?php
include('SMTPClass.php');
$use_smtp = '0';
$emailto = 'rpetrow@interia.pl';
// retrieve from parameters
$emailfrom = isset($_POST["email"]) ? $_POST["email"] : "";
$nocomment = isset($_POST["nocomment"]) ? $_POST["nocomment"] : "";
$subject = 'Email z AudiA3';
$message = '';
$response = '';
$response_fail = 'There was an error verifying your details.';
// Honeypot captcha
if($nocomment == '') {
$params = $_POST;
foreach ( $params as $key=>$value ){
if(!($key == 'ip' || $key == 'emailsubject' || $key == 'url' || $key == 'emailto' || $key == 'nocomment' || $key == 'v_error' || $key == 'v_email')){
$key = ucwords(str_replace("-", " ", $key));
if ( gettype( $value ) == "array" ){
$message .= "$key: \n";
foreach ( $value as $two_dim_value )
$message .= "...$two_dim_value<br>";
}else {
$message .= $value != '' ? "$key: $value\n" : '';
}
}
}
$response = sendEmail($subject, $message, $emailto, $emailfrom);
} else {
$response = $response_fail;
}
echo $response;
// Run server-side validation
function sendEmail($subject, $content, $emailto, $emailfrom) {
$from = $emailfrom;
$response_sent = 'Thank you. Your comments have been received.';
$response_error = 'Error. Please try again.';
$subject = filter($subject);
$url = "Wysłano z: ".$_SERVER['HTTP_REFERER'];
$ip = "IP Adres: ".$_SERVER["REMOTE_ADDR"];
$message = $content."\n$ip\r\n$url";
// Validate return email & inform admin
$emailto = filter($emailto);
// Setup final message
$body = wordwrap($message);
if($use_smtp == '1'){
$SmtpServer = 'SMTP SERVER';
$SmtpPort = 'SMTP PORT';
$SmtpUser = 'SMTP USER';
$SmtpPass = 'SMTP PASSWORD';
$to = $emailto;
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();
$response = $SMTPChat ? $response_sent : $response_error;
} else {
// Create header
$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: quoted-printable\r\n";
// Send email
$mail_sent = @mail($emailto, $subject, $body, $headers);
$response = $mail_sent ? $response_sent : $response_error;
}
return $response;
}
// Remove any un-safe values to prevent email injection
function filter($value) {
$pattern = array("/\n/", "/\r/", "/content-type:/i", "/to:/i", "/from:/i", "/cc:/i");
$value = preg_replace($pattern, "", $value);
return $value;
}
exit;
?>
$response_sent = 'Thank you. Your comments have been received.';
ten thank you .....
i wiadomość na dany e-mail nie dochodzi
mam drugi folder potwierdzenie i tam mam plik kontakt.php
Kod: Zaznacz cały
<?php
// Tworzymy zmienną dla imienia i nazwiska
$name = $_POST['name'];
// Tworzymy zmienną dla adresu email
$email = $_POST['email'];
// Tworzymy zmienną dla telefonu
$phone = $_POST['Phone'];
// Tworzymy zmienną dla wiadomości
$message = $_POST['message'];
// Podajesz adres email z którego ma być wysłana wiadomość
$odkogo = "RobertPetrow@cba.pl";
// Podajesz adres email na który chcesz otrzymać wiadomość
$dokogo = "rpetrow@interia.pl";
// Podajesz tytuł jaki ma mieć ta wiadomość email
$tytul = "Email z forum";
// Przygotowujesz treść wiadomości
$wiadomosc = "";
$wiadomosc .= "Imie i nazwisko: " . $name . "\n";
$wiadomosc .= "Email: " . $email . "\n";
$wiadomosc .= "Telefon: " . $phone . "\n";
$wiadomosc .= "Wiadomość: " . $message . "\n";
// Wysyłamy wiadomość
$sukces = mail($dokogo, $tytul, $wiadomosc, $naglowek);
// Przekierowywujemy na potwierdzenie
if ($sukces){
print "<meta http-equiv=\"refresh\" content=\"0;URL=potwierzenie\potwierdzenie.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>
trzeba coś na cba mieć włączone !?