Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Nie pokazuje maila nadawcy tylko mail serwera?
Forum PHP.pl > Forum > Przedszkole
kostykiewicz
Witam,
Po wypełnieniu formularz (scrren poniżej) skierowana jest do mnie czyli do odbiorcy. Ale adres e-mail który podejemy podczas wypełnienia tego formularza nie pojawia się ten co ma być tylko adres e-mail serwera głównego po przez który przechodzi konto tzn. nazwa_konta_na_serwerze@subdomena_serwera.domena_glownaserwera.pl

A powinien być mail który wpisałem.
Ostatnio na serwerze w nazwa.pl był ten formularz i nie było problemu a jak przeniosłem do innego hostingodawcy to właśnie tak się pojawia.

Czy możecie państwo podpowiedzieć co tu można zrobić?





form.php

  1. <?php
  2.  
  3. // you MUST include the config.php file before your form
  4. include 'mail/config.php';
  5.  
  6.  
  7. // You can edit the form fields below if you like
  8. // but you must leave intact all parts which are indicated
  9. // with comments
  10. ?>
  11. <!-- if you want to use basic JavaScript validation, keep the JS file call below -->
  12. <script src="mail/validation.js"></script>
  13. <script>
  14. // SPECIFY ALL REQUIRED FIELDS AND
  15. // SEE validation.js for other options
  16. required.add('imie_nazwisko', 'NOT_EMPTY');
  17. required.add('email', 'EMAIL');
  18. required.add('tesc', 'NOT_EMPTY');
  19. required.add('telefon', 'NOT_EMPTY');
  20. required.add('answer_out', 'NUMERIC');
  21. </script>
  22. <link rel="stylesheet" type="text/css" href="mail/form_style.css" /><style type="text/css">
  23.  
  24. </style><form name="fcform2" method="post" action="mail/process_form.php" onsubmit="return validate.check()">
  25. <div id="fcf2">
  26.  
  27. <div class="r">
  28. <label for="imie_nazwisko" class="req">Imię i Nazwisko: <em>*</em></label>
  29. <span class="f">
  30. <input type="text" name="imie_nazwisko" size="30" id="imie_nazwisko" onBlur="trim('imie_nazwisko')">
  31. </span>
  32. </div>
  33.  
  34. <div class="r">
  35. <label for="email" class="req">E-mail adres: <em>*</em></label>
  36. <span class="f">
  37. <input type="text" name="email" size="30" id="email" onBlur="trim('email')">
  38. </span>
  39. </div>
  40.  
  41. <div class="r">
  42. <label for="telefon"><strong>Telefon:</strong> <span class="req"> <em>*</em></span></label>
  43. <span class="f">
  44. <input type="text" name="telefon" size="30" id="telefon" onBlur="trim('telefon')">
  45. </span>
  46. </div>
  47.  
  48. <div class="r">
  49. <label for="tesc" class="req">Wiadomość: <em>*</em></label>
  50. <span class="f">
  51. <textarea cols="25" rows="3" name="tesc" id="tesc" onBlur="trim('tesc')"></textarea>
  52. </span>
  53. </div>
  54.  
  55. <!-- the section below MUST remain for the magic to work -->
  56. <!-- although feel free to change the style / layout -->
  57. <div class="r">
  58. <label for="quest" class="req"><?php echo $question; ?> <em>*</em></label>
  59. <span class="f">
  60. <input type="text" name="answer_out" size="6" id="answer_out" onBlur="trim('answer_out')">
  61. &nbsp;
  62.  
  63. Podaj wynik działania
  64.  
  65. </span>
  66. </div>
  67. <!-- section above must remain -->
  68.  
  69.  
  70. <div class="sp">&nbsp;</div>
  71.  
  72. <?php
  73. if(isset($_GET['done'])) {
  74. echo '<div align="center" style="color:#000000;font-weight:bold">'.$confirmation_message.'</div><br />';
  75. }
  76. ?>
  77. <div align="center">
  78. <input type="submit" value="Wyślij">
  79. </div>
  80. </div>
  81.  
  82. <!-- the 2 hidden fields below must REMAIN for the magic to work -->
  83. <input type="hidden" name="answer_p" value="<?php echo $answer_pass; ?>">
  84. <input type="hidden" name="enc" value="<?php echo $enc; ?>">
  85. <!-- above 2 hidden fields MUST remain -->
  86.  
  87. </form>




process_form.php


  1. <?php
  2.  
  3. // THIS CODE IS KEPT LINEAR FOR EASE OF USER UNDERSTANDING
  4. include 'config.php';
  5.  
  6.  
  7. // set-up redirect page
  8. if($send_back_to_form == "yes") {
  9. $redirect_to = $form_page_name."?done=1";
  10. } else {
  11. $redirect_to = $success_page;
  12. }
  13.  
  14.  
  15. if(isset($_POST['enc'])) {
  16.  
  17.  
  18. /* THIS IS THE NEW FORM VALIDATION SECTION */
  19. include 'validation.class.php';
  20.  
  21.  
  22. // function to handle errors
  23. function error_found($mes,$failure_accept_message,$failure_page) {
  24. if($failure_accept_message == "yes") {
  25. $qstring = "?prob=".urlencode(base64_encode($mes));
  26. } else {
  27. $qstring = "";
  28. }
  29. $error_page_url = $failure_page."".$qstring;
  30. header("Location: $error_page_url");
  31. die();
  32. }
  33.  
  34.  
  35. /* SET REQUIRED */
  36. $reqobj = new required;
  37. // ADD ALL REQUIRED FIELDS TO VALIDATE!
  38. $reqobj->add("imie_nazwisko","NOT_EMPTY");
  39. $reqobj->add("email","EMAIL");
  40. $reqobj->add("tesc","NOT_EMPTY");
  41. $reqobj->add("telefon","NOT_EMPTY");
  42. $reqobj->add("answer_out","NUMERIC");
  43. $out = $reqobj->out();
  44. $val = new validate($out, $_POST);
  45. if($val->error) {
  46. $er = $val->error_string;
  47. error_found($er,$failure_accept_message,$failure_page);
  48. die();
  49. }
  50.  
  51. // check for any human hacking attempts
  52. class clean {
  53. function comments($message) {
  54. $this->naughty = false;
  55. $this->message = $message;
  56. $bad = array("content-type","bcc:","to:","cc:","href");
  57. $for = array( "\r", "\n", "%0a", "%0d");
  58. foreach($bad as $b) {
  59. if(eregi($b, $this->message)) {
  60. $this->naughty = true;
  61. }
  62. }
  63. $this->message = str_replace($bad,"#removed#", $this->message);
  64. $this->message = stripslashes(str_replace($for, ' ', $this->message));
  65.  
  66. // check for HTML/Scripts
  67. $length_was = strlen($this->message);
  68. $this->message = strip_tags($this->message);
  69. if(strlen($this->message) < $length_was) {
  70. $this->naughty = true;
  71. }
  72. }
  73. } // class
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. /* validate the encrypted strings */
  88. $dec = false;
  89. $valid = false;
  90.  
  91. $dec = valEncStr(trim($_POST['enc']), $mkMine);
  92. if($dec == true) {
  93. $valid = true;
  94. } else {
  95. $er = "Nieprawidlowo wpisales dane.<br />$dec";
  96. error_found($er,$failure_accept_message,$failure_page);
  97. die();
  98. }
  99.  
  100.  
  101. // check the spam question has the correct answer
  102. $ans_one = $_POST['answer_out'];
  103. $fa = new encdec;
  104. $ans_two = $fa->decrypt($_POST['answer_p']);
  105.  
  106. if($ans_one === $ans_two) {
  107. $valid = true;
  108. } else {
  109. $er ='Twoj wynik dzialania jest nieprawidlowy.';
  110. error_found($er,$failure_accept_message,$failure_page);
  111. die();
  112. }
  113.  
  114.  
  115.  
  116. if($valid) {
  117. $from = $_POST['email'];
  118. $email_message = "Wiadomosc wyslana dnia ".date("Y-m-d")."\n\n<br><br>";
  119.  
  120. // loop through all form fields submitted
  121. // ignore all fields used for security measures
  122. foreach($_POST as $field_name => $field_value) {
  123. if($field_name == "answer_out" || $field_name == "answer_p" || $field_name == "enc") {
  124. // do not email these security details
  125. } else {
  126. // run all submitted content through string checker
  127. // removing any dangerous code
  128. $ms = new clean;
  129. $ms->comments($field_value);
  130. $is_naughty = $ms->naughty;
  131. $this_val = $ms->message;
  132. $email_message .= $field_name.": ".$this_val."\n\n<br><br>";
  133. }
  134. }
  135.  
  136. if($is_naughty) {
  137. if($accept_suspected_hack == "yes") {
  138. // continue
  139. } else {
  140. // pretend the email was sent
  141. header("Location: $redirect_to");
  142. die();
  143. }
  144. $email_subject = $email_suspected_spam;
  145. }
  146.  
  147. // create email headers
  148. $headers = 'From: '.$from."\r\n" .
  149. 'Reply-To: '.$from."\r\n" .
  150. 'X-Mailer: PHP/' . phpversion();
  151. $headers = "Content-Type: text/html; charset=utf-8\r\n";
  152. // send the email
  153. @mail($email_it_to, $email_subject, $email_message, $headers, $from);
  154. // redirect
  155. header("Location: $redirect_to");
  156. die();
  157. }
  158.  
  159. } else {
  160.  
  161. extract($_POST);
  162. if(isset($enc)) {
  163. echo "register globals may be on, please switch this setting off (look at php.net for details, specifically the ini_set() function )";
  164. } else {
  165. die('There was an error, please check the form was configured properly.');
  166. }
  167.  
  168. }
  169. ?>



emstawicki
Dlaczego nagłówek From chcesz ustawiać jako pole z formularza - to bardzo zła praktyka, bo to nie ten nadawca fizycznie wysyła maila, tylko twój automat.
kostykiewicz
Chodzi mi o taką kwestię.
Jest sobie np. serwer nazwa.pl


Mam konto hostingowe: moj_hosting.nazwa.pl (w takiej subdomenie)

Jeśli wiadomość z tego formularza jest wysyłana do mnie to otrzymuje: subdomena.nazwa.pl

I jak osoba da odrazu odeślij tzn. odpowiedz to odpowiada na subdomena.nazwa.pl (i wtedy wiadomośc moze trafić na kontakt@subdomena.nazwa.pl) która może nigdzie nie być odsyłana dalej.


Jesli klient podaje w formularzu swój mail;
To jak np. ja dostaje ten mail i dam odpowiedz to odpowiadam pod tego maila który podal wypełniający formularz.

Jak to zrobić za pomocą tego formularza.
emstawicki
Po to wymyślono nagłówek `Reply-To`.

Czyli w uproszczeniu maila wysyłasz z noreply@twojadomena albo automat@twojadomena a o odpowiedź prosisz na np. skrzynka_prywatna@php.pl
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.