Posiadam kod formularza kontaktowego e-mail.
?<!DOCTYPE html> <html lang="pl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <META HTTP-EQUIV="CONTENT-LANGUAGE" CONTENT="PL"> <!-- Main CSS Stylesheet --> <link rel="stylesheet" type="text/css" href="css/style.css"> <!-- Google Web Fonts --> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:400,300,500,600,700"> </head> <body> <?php $twojemail = "twój@mail.pl"; //na jaki adres ma zostać wysłana treść z formularza $blad=0; // filtrowanie treści wprowadzonych przez użytkownika $temat = "Formularz kontaktowy"; // temat wiadomości // sprawdzamy czy wszystkie pola zostały wypełnione if (!$name) { $blad++; } if (!$email) { $blad++; } if (!$message) { $blad++; } // jeżeli nie ma błędu, to wiadomość e-mail zostaje wysłana if ($blad == 0) { // niezbędne nagłówki do wyświetlania wiadomości HTML $naglowki = "MIME-Version: 1.0" . "\r\n"; $naglowki .= "Content-type:text/html;charset=utf-8" . "\r\n"; // opcjonalne nagłówki $naglowki .= 'From: <'.$email.'>' . "\r\n"; $naglowki .= 'Cc: <'.$twojemail.'>' . "\r\n"; // całkowita treść wiadomości $wiadomosc = <<< KONIEC <html> <p><strong>Imię i nazwisko:</strong> $name</p> <p><strong>Telefon:</strong><br /> $tel</p> <p><strong>E-mail:</strong> $email</p> <p><strong>Wybrany temat:</strong><br /> $subject</p> <p><strong>Wiadomość:</strong><br /> $message</p> </html> KONIEC; // wysyłanie wiadomości e-mail // komunikat potwierdzający wysłanie wiadomości bądź nie if ($wynik) { echo ' <div class="section-title"> <p></p> <p></p> <h2>Dziękujemy</h2> <p><Strong>Wiadomość została wysłana</strong></p> <p>Za chwilę nastąpi przekierowanie na stronę startową.</p> </div>'; } else { echo ' <div class="section-title"> <h2>blad</h2> </div>'; } } } ?> <meta http-equiv="refresh" content="10; url=d/index.html" />? </body> </html>
Umieściłem go sobie do testów na pierwszym lepszym serwerze darmowym cba.pl, gdzie posiadam zarejestrowaną domenę e-mail. Formularz działa, wysyła maile tylko i wyłącznie gdy w 19 linijce PHP podam adres mail jaki mam zarejestrowany na cda.pl oraz gdy w samym formularzu na stronie index.html, w miejscu na e-mail, podam ten sam e-mail z portalu cda.pl, jeśli tu lub tu podam jakikolwiek inny e-mail, formularz niczego nie wysyła. Serdecznie proszę o pomoc, jak to rozwiązać, by formularz wysyłał maile na inne adresy.
<div class="row"> <form method="post" name="contactform" action="mail.php"> <div class="col-sm-6"> <div class="form-group"> <input type="text" name="name" id="name" class="form-control" placeholder=> </div> </div> <div class="col-sm-6"> <div class="form-group"> <input type="text" name="email" id="email" class="form-control" placeholder="* Adres e-mail"> </div> </div> <div class="col-sm-6"> <select id="subject" name="subject" class="form-group form-control"> </select> </div> <div class="col-sm-6"> <div class="form-group"> <input type="text" name="tel" id="tel" class="form-control" placeholder="* Numer telefonu"> </div> </div> <div class="col-sm-12"> <div class="textarea-message form-group"> </div> </div> <div> </div> <div class="text-center"> </div> </form> </div>