Wysylanie maila przez PHP-a

0

Chcialbym napisac formularz kontaktowy na strone niestety niby wszystko jest ok a maila nie dostaje.
korzystam w ramach testowych z https://www.cba.pl/
kod w html-u:

<html>
<head>	
	<link rel="stylesheet" type="text/css" href="formularz.css"></link>
</head>
<body>
<main> 
	<div id="formularz">
		<form method="post" action="formularz.php">
			<label>Imię i nazwisko</label>
			<input name="name" type="text" placeholder="Imie Nazwisko">

			<label>Email</label>
			<input name="email" type="email" placeholder="[email protected]">
						
			<label>Numer telefonu</label>
			<input type="tel" name="usrtel" placeholder="123 456 789">

			<label>Temat</label>
			<input name="temat" placeholder="temat"></input>
			
			<label>Wiadomość</label>
			<textarea name="message" placeholder="Napisz tu wiadomość"></textarea>
								
			<input id="submit" name="submit" type="submit" value="Wyślij">
		</form>
		<div id=stopka>
			<strong>Wypełnij pola, <br> nacisnij wyślij, <br> na pewno odpowiemy!</strong>
		</div>
	</div>
</main>	
</body>
</html>

i wysylanie maila w PHP-ie

<?php

$name = $_POST['name'];

$email = $_POST['email'];

$message = $_POST['message'];

$usrtel = $_POST['usrtel'];

$tytul = $_POST['temat'];


// Tu podajesz adres email na który chcesz otrzymać wiadomość
$dokogo = "tu podaje moj mail";


//treść wiadomości
$wiadomosc = "";
$wiadomosc .= "Imie i nazwisko: " . $name . "\n";
$wiadomosc .= "Email: " . $email . "\n";
$wiadomosc .= "Tel: " . $usrtel . "\n";
$wiadomosc .= "Wiadomość: " . $message . "\n";

$naglowek = "";
$naglowek .= "Od:" . $odkogo . " \n";
$naglowek .= "Content-Type:text/plain;charset=utf-8";

$sukces = mail($dokogo, $tytul, $wiadomosc, $naglowek);

if ($sukces){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=potwierdzenie.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

Czy cos tu zle robie? Niestety po nacisnieciu wyslij przechodzi mi do potwierdzenia ale nie mam nic na swoim mailu :(

0

jak dla mnie mocno średnie, polskie nazwy wyglądają dziwnie, brak walidacji więc kupa spamu na skrzynce, zoba tu:
https://bootstrapious.com/p/how-to-build-a-working-bootstrap-contact-form
https://webdesign.tutsplus.com/tutorials/building-a-bootstrap-contact-form-using-php-and-ajax--cms-23068

0

na razie chcialbym zeby mi doszedł mail :(
pozniej bede myslal nad poprawianiem tego.
czy powinno mi to dzialać jesli na serwerze jest włączona funkcja mail();

1

Na Twoim miejscu w takim razie zainteresowałbym się PHPMailerem, a później nad walidacją wysyłki.

0

Wiem ze jest cos takiego jak PHPmailer ale chcialbym tylko wiedziec czy ten kod tez powinien zadzialac. Bo niestety jak korzystam z hostingu cba to pisze ze dziala ale maila nie dostaje (w spamie tez nie ma):(

0

Poczytaj dokładnie manuala - co piszą o tej funkcji. Może tutaj leży problem?

Note:
additional_headers does not have mail header injection protection. Therefore, users must make sure specified headers are safe and contains headers only. i.e. Never start mail body by putting multiple newlines.

Note:
When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

Note:
If messages are not received, try using a LF (\n) only. Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.

Przed wysłaniem maila sprawdź dokładnie adres. Sprawdź czy nie wkradły Ci się jakieś dodatkowe znaki, albo coś jest nie tak z kodowaniem.

1 użytkowników online, w tym zalogowanych: 0, gości: 1