Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Problem z formularzem php mail.
Forum PHP.pl > Forum > Przedszkole
samud
Witam.
Problem wyglada następująco:
Wysyłam maila przez formularz ze strony, wiadomość dochodzi ale nie można na nią odpowiedzieć ponieważ w polu "od" adres zlewa się z innymi informacjami.
przykladowy@gmail.comrnReply-To: przykladowy@gmail.comrnX-Mailer: PHP/5.5.23

Mógłby ktoś mi pomóc w rozwiazaniu tego problemu?
Pozdrawiam

CODE
<?php
if($_POST)
{
//check if its an ajax request, exit if not
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
die();
}

$to_Email = "przykladowy@mail.com"; //Replace with recipient email address
$subject = 'E-mail ze strony Mar-Bud'; //Subject line for emails

//check $_POST vars are set, exit if any missing
if(!isset($_POST["userName"]) || !isset($_POST["userEmail"]) || !isset($_POST["userMessage"]))
{
die();
}

//Sanitize input data using PHP filter_var().
$user_Name = filter_var($_POST["userName"], FILTER_SANITIZE_STRING);
$user_Email = filter_var($_POST["userEmail"], FILTER_SANITIZE_EMAIL);
$user_Message = filter_var($_POST["userMessage"], FILTER_SANITIZE_STRING);

//additional php validation
if(strlen($user_Name)<4) // If length is less than 4 it will throw an HTTP error.
{
header('HTTP/1.1 500 Name is too short or empty!');
exit();
}
if(!filter_var($user_Email, FILTER_VALIDATE_EMAIL)) //email validation
{
header('HTTP/1.1 500 Please enter a valid email!');
exit();
}
if(strlen($user_Message)<5) //check emtpy message
{
header('HTTP/1.1 500 Too short message! Please enter something.');
exit();
}

//proceed with PHP email.
$headers = 'From: '.$user_Email.'' . "rn" .
'Reply-To: '.$user_Email.'' . "rn" .
'X-Mailer: PHP/' . phpversion();

@$sentMail = mail($to_Email, $subject, $user_Message .' -'.$user_Name, $headers);

if(!$sentMail)
{
header('HTTP/1.1 500 Could not send mail! Sorry..');
exit();
}else{
echo 'Witaj '.$user_Name .', E-mail wyslano! ';
}
}
?>
KsaR
  1. //proceed with PHP email.
  2. $headers = 'From: '.$user_Email.'' . "rn" .
  3. 'Reply-To: '.$user_Email.'' . "rn" .
  4. 'X-Mailer: PHP/' . phpversion();

Nie "rn" tylko "\r\n"

Btw, jak mozesz to uzywaj do php tagu [ php ] zamiast [ code ], pokoloruje skladnie i nie trzeba scrollowac.
samud
Cytat(KsaR @ 7.11.2015, 02:40:58 ) *
  1. //proceed with PHP email.
  2. $headers = 'From: '.$user_Email.'' . "rn" .
  3. 'Reply-To: '.$user_Email.'' . "rn" .
  4. 'X-Mailer: PHP/' . phpversion();

Nie "rn" tylko "\r\n"

Btw, jak mozesz to uzywaj do php tagu [ php ] zamiast [ code ], pokoloruje skladnie i nie trzeba scrollowac.


Dzięki Dzięki Dobry Człowieku exclamation.gif! smile.gif Działa jak trzeba.
A do rady się zastosuje!
Pozdrawiam.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.