Witam,

Proszę o pomoc. Skrypt nie działa tak jak trzeba. Zamiast załączać pliki do wiadomości e-mail przychodzi tekst. To jest chyba jakiś problem z kodowaniem.
Próbowałem zmieniać kodowanie, ale dalej to samo.

Oto kod:

  1. <?php
  2.  
  3. // This will show in the browsers title bar and at the top of the form.
  4. $websitename="Wypełnij formularz zgłoszenia szkody";
  5.  
  6. // Allowed file types. Please remember to keep the format of this array, add the file extensions you want
  7. // WITHOUT the dot. Please also be aware that certain file types (such as exe) may contain malware.
  8. $allowtypes=array("zip", "rar", "docx", "doc", "jpg", "png", "gif", "odt", "pdf");
  9.  
  10. // What's your email address? Seperate email addresses with commas for multiple email addresses.
  11. $myemail="getsemane3@gmail.com";
  12.  
  13. // What priority should the script send the mail? 1 (Highest), 2 (High), 3 (Normal), 4 (Low), 5 (Lowest).
  14. $priority="1";
  15.  
  16. // Should we allow visitors to attach files? How Many? 0 = Do not allow attachments,
  17. // 1 = allow only 1 file to be attached, 2 = allow two files etc.
  18. $allowattach="4";
  19.  
  20. // Maximum file size for attachments in KB NOT Bytes for simplicity. MAKE SURE your php.ini can handel it,
  21. // post_max_size, upload_max_filesize, file_uploads, max_execution_time!
  22. // 2048kb = 2MB, 1024kb = 1MB, 512kb = 1/2MB etc..
  23. $max_file_size="1024";
  24.  
  25. // Maximum file size for all attachments combined in KB. MAKE SURE your php.ini can handel it,
  26. // post_max_size, upload_max_filesize, file_uploads, max_execution_time!
  27. // 2048kb = 2MB, 1024kb = 1MB, 512kb = 1/2MB etc..
  28. $max_file_total="2048";
  29.  
  30. // Value for the Submit Button
  31. $submitvalue=" Wyślij e-mail ";
  32.  
  33. // Value for the Reset Button
  34. $resetvalue=" Resetuj ";
  35.  
  36. // Default subject? This will be sent if the user does not type in a subject
  37. $defaultsubject="Brak tematu";
  38.  
  39. // Because many requested it, this feature will add a drop down box for the user to select a array of
  40. // subjects that you specify below.
  41. // True = Use this feature, False = do not use this feature
  42. $use_subject_drop=true;
  43.  
  44. // This is an array of the email subjects the user can pick from. Make sure you keep the format of
  45. // this array or you will get errors.
  46. // Look at <http://novahq.net/forum/showthread.php?t=38718> for examples on how to use this feature.
  47. $subjects=array("Szkoda z OC", "Szkoda z AC");
  48.  
  49. // This is an array of the email addresses for the array above. There must be an email FOR EACH
  50. // array value specified above. You can have only 1 department if you want.
  51. // YOU MUST HAVE THE SAME AMMOUNT OF $subjects and $emails or this WILL NOT work correctly!
  52. // The emails also must be in order for what you specify above!
  53. // Seperate email addresses by a comma to send an email to multiple addresses.
  54. $emails=array("getsemane3@gmail.com", "getsemane3@gmail.com");
  55.  
  56. // This is the message that is sent after the email has been sent. You can use html here.
  57. // If you want to redirect users to another page on your website use this:
  58. // <script type=\"text/javascript\">window.location=\"http://www.YOUR_URL.com/page.html\";</script>
  59. $thanksmessage="Dziękujemy, Twój e-mail został poprawnie wysłany. Skontaktujemy się z Tobą najszybciej jak to będzie możliwe.";
  60.  
  61. /*
  62. //================================================================================
  63. * ! ATTENTION !
  64. //================================================================================
  65. : Don't edit below this line.
  66. */
  67.  
  68. // Function to get the extension of the uploaded file.
  69. function get_ext($key) {
  70. $key=strtolower(substr(strrchr($key, "."), 1));
  71. $key=str_replace("jpeg", "jpg", $key);
  72. return $key;
  73. }
  74.  
  75. // Function used to attach files to the message
  76. function phattach($file, $name, $boundary) {
  77.  
  78. $fp=fopen($file, "r");
  79. $str=fread($fp, filesize($file));
  80. $message="--".$boundary."\n";
  81. $message.="Content-Type: application/octet-stream; name=\"".$name."\"\n";
  82. $message.="Content-disposition: attachment; filename=\"".$name."\"\n";
  83. $message.="Content-Transfer-Encoding: base64\n";
  84. $message.="\n";
  85. $message.="$str\n";
  86. $message.="\n";
  87.  
  88. return $message;
  89. }
  90.  
  91. //Little bit of security from people forging headers. People are mean sometimes :(
  92. function clean_msg($key) {
  93. $key=str_replace("\r", "", $key);
  94. $key=str_replace("\n", "", $key);
  95. $find=array(
  96. "/bcc\:/i",
  97. "/Content\-Type\:/i",
  98. "/Mime\-Type\:/i",
  99. "/cc\:/i",
  100. "/to\:/i"
  101. );
  102. $key=preg_replace($find, "", $key);
  103. return $key;
  104. }
  105.  
  106. // Initilize some variables
  107. $error="";
  108. $sent_mail=false;
  109.  
  110. // When the form is submitted
  111. If($_POST['submit']==true) {
  112. extract($_POST, EXTR_SKIP);
  113.  
  114. // Check the form for errors
  115. If(trim($yourname)=="") {
  116. $error.="Nie wpisałeś imienia i nazwiska!<br />";
  117. }
  118.  
  119. If(trim($yourphone)=="") {
  120. $error.="Nie wpisałeś numeru telefonu!<br />";
  121. }
  122.  
  123. If(trim($youremail)=="") {
  124. $error.="Nie wpisałeś adresu e-mail!<br />";
  125. } Elseif(!preg_match("/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/", $youremail)) {
  126. $error.="Niepoprawny adres e-mail.<br />";
  127. }
  128.  
  129. If(trim($emailsubject)=="") {
  130. $emailsubject=$defaultsubject;
  131. }
  132.  
  133. If(trim($yourmessage)=="") {
  134. $error.="Nie wpisałeś wiadomości!<br />";
  135. }
  136.  
  137. // Verify Attchment info
  138. If($allowattach > 0) {
  139.  
  140. // Get the total size of all uploaded files
  141. If((array_sum($_FILES['attachment']['size'])) > ($max_file_total*1024)) {
  142.  
  143. $error.="Maksymalny rozmiar wszystkich plików wynosi ".$max_file_total."kb<br />";
  144.  
  145. } Else {
  146.  
  147. //Loop through each of the files
  148. For($i=0; $i <= $allowattach-1; $i++) {
  149.  
  150. If($_FILES['attachment']['name'][$i]) {
  151.  
  152. //Check if the file type uploaded is a valid file type.
  153. If(!in_array(get_ext($_FILES['attachment']['name'][$i]), $allowtypes)) {
  154.  
  155. $error.= "Niepoprawne rozszerzenie pliku: ".$_FILES['attachment']['name'][$i]."<br />";
  156.  
  157. //Check the size of each file
  158. } Elseif(($_FILES['attachment']['size'][$i]) > ($max_file_size*1024)) {
  159.  
  160. $error.= "Twój załącznik: ".$_FILES['attachment']['name'][$i]." jest za duży.<br />";
  161.  
  162. } // If in_array
  163.  
  164. } // If Files
  165.  
  166. } // For
  167.  
  168. } // Else array_sum($_FILES['attachment']['size'])
  169.  
  170. } // If Allowattach
  171.  
  172. If($error) {
  173.  
  174. $display_message=$error;
  175.  
  176. } Else {
  177.  
  178. If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {
  179. $subject_count=count($subjects);
  180. $email_count=count($emails);
  181.  
  182. If($subject_count==$email_count) {
  183.  
  184. $myemail=$emails[$emailsubject];
  185. $emailsubject=$subjects[$emailsubject];
  186.  
  187. } // If $subject_count
  188.  
  189. } // If $use_subject_drop
  190.  
  191. $boundary=md5(uniqid(time()));
  192.  
  193. //Headers
  194. $headers="Return-Path: <".clean_msg($youremail).">\n";
  195. $headers.="From: ".clean_msg($yourname)." <".clean_msg($youremail).">\n".clean_msg($yourphone).">\n";
  196. $headers.="X-Mailer: PHP/".phpversion()."\n";
  197. $headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
  198. $headers.="X-Priority: ".$priority."\n";
  199. $headers.="MIME-Version: 1.0\n";
  200. $headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
  201. $headers.="This is a multi-part message in MIME format.\n";
  202.  
  203. //Message
  204. $message = "--".$boundary."\n";
  205. $message.="Content-Type: text/html; charset=\"UTF-8\"\n";
  206. $message.="Content-Transfer-Encoding: quoted-printable\n";
  207. $message.="\n";
  208. $message.=clean_msg(nl2br(strip_tags($yourmessage)));
  209. $message.="\n";
  210.  
  211. //Add attachments to message
  212. If($allowattach > 0) {
  213.  
  214. For($i=0; $i <= $allowattach-1; $i++) {
  215.  
  216. If($_FILES['attachment']['tmp_name'][$i]) {
  217.  
  218. $message.=phattach($_FILES['attachment']['tmp_name'][$i], $_FILES['attachment']['name'][$i], $boundary);
  219.  
  220. } //If $_FILES['attachment']['name'][$i]
  221.  
  222. } //For
  223.  
  224. } // If
  225.  
  226. // End the message
  227. $message.="--".$boundary."--\n";
  228.  
  229. // Send the completed message
  230. If(!mail($myemail, clean_msg($emailsubject), $message, $headers)) {
  231.  
  232. Exit("An error has occured, please report this to the website administrator.\n");
  233.  
  234. } Else {
  235.  
  236. $sent_mail=true;
  237.  
  238. }
  239.  
  240. } // Else
  241.  
  242. } // $_POST
  243.  
  244. /*
  245. //================================================================================
  246. * Start the form layout
  247. //================================================================================
  248. :- Use the html below to customize the form.
  249. */
  250. ?>


  1. [html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <meta http-equiv="Content-Language" content="pl" />
  4. <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
  5. <title><?php echo $websitename; ?> - Powered By phMailer</title>
  6.  
  7. <link rel="stylesheet" type="text/css" href="css/demo.css" />
  8. <link rel="stylesheet" type="text/css" href="css/style1.css" />
  9. <script type="text/javascript" src="js/jssor.js"></script>
  10. <script type="text/javascript" src="js/jssor.slider.js"></script>
  11. init_jssor_slider1 = function (containerId) {
  12.  
  13. var options = {
  14. $AutoPlay: true, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
  15. $SlideDuration: 1000, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500
  16.  
  17. $BulletNavigatorOptions: { //[Optional] Options to specify and enable navigator or not
  18. $Class: $JssorBulletNavigator$, //[Required] Class to create navigator instance
  19. $ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always
  20. $AutoCenter: 1, //[Optional] Auto center navigator in parent container, 0 None, 1 Horizontal, 2 Vertical, 3 Both, default value is 0
  21. $Steps: 1, //[Optional] Steps to go for each navigation request, default value is 1
  22. $Lanes: 1, //[Optional] Specify lanes to arrange items, default value is 1
  23. $SpacingX: 10, //[Optional] Horizontal space between each item in pixel, default value is 0
  24. $SpacingY: 10, //[Optional] Vertical space between each item in pixel, default value is 0
  25. $Orientation: 1 //[Optional] The orientation of the navigator, 1 horizontal, 2 vertical, default value is 1
  26. }
  27. };
  28.  
  29. var jssor_slider1 = new $JssorSlider$(containerId, options);
  30. }
  31. </script>
  32.  
  33. <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  34. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  35. <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  36. <link rel="stylesheet" href="/resources/demos/style.css">
  37. $(function() {
  38. $( "#menu" ).menu();
  39. });
  40. </script>
  41. .ui-menu { width: 150px; }
  42. </style>
  43.  
  44. <!-- tutaj były style -->
  45.  
  46. <script type="text/javascript">
  47. var error="";
  48. e_regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
  49.  
  50. function Checkit(theform) {
  51. if(theform.yourname.value=="") {
  52. error+="Nie wpisałeś swojego imienia.\n";
  53. }
  54.  
  55. if(theform.yourphone.value=="") {
  56. error+="Nie wpisałeś numeru telefonu.\n";
  57. }
  58.  
  59. if(theform.youremail.value=="") {
  60. error+="Nie wpisałeś swojego adresu e-mail.\n";
  61. } else if(!e_regex.test(theform.youremail.value)) {
  62. error+="Niepoprawny adres e-mail.\n";
  63. }
  64.  
  65. if(theform.yourmessage.value=="") {
  66. error+="Nie wpisałeś wiadomości.\n";
  67. }
  68.  
  69. if(error) {
  70. alert('**Formularz zwrócił następujące błędy:**\n\n' + error);
  71. error="";
  72. return false;
  73. } else {
  74. return true;
  75. }
  76. }
  77.  
  78. </head>
  79. <?If($display_message) {?>
  80.  
  81. <div align="center" class="error_message"><b><?=$display_message;?></b></div>
  82. <br />
  83.  
  84. <?}?>
  85.  
  86. <?If($sent_mail!=true) {?>
  87.  
  88. <form method="post" action="<?=$_SERVER['PHP_SELF'];?>" enctype="multipart/form-data" name="phmailer" onsubmit="return Checkit(this);">
  89. <table align="center" class="table">
  90.  
  91.  
  92.  
  93. <tr>
  94.  
  95. <td width="50%" class="table_body"><input name="yourname" placeholder="Imię i nazwisko" type="text" size="30" value="<?=stripslashes(htmlspecialchars($yourname));?>" /><span class="error_message">*</span></td>
  96. <td width="50%" class="table_body"><input name="youremail" placeholder="Twój e-mail" type="text" size="30" value="<?=stripslashes(htmlspecialchars($youremail));?>" /><span class="error_message">*</span></td>
  97. </tr>
  98.  
  99. <tr>
  100.  
  101. <td>&nbsp;</td>
  102. <td width="50%" class="table_body"><input name="yourphone" placeholder="Twój numer telefonu" type="text" size="30" value="<?=stripslashes(htmlspecialchars($yourphone));?>" /><span class="error_message">*</span></td>
  103. </tr>
  104.  
  105. <tr>
  106. <td width="50%" class="table_body">Wybierz rodzaj szkody:</td>
  107. <td width="50%" class="table_body">
  108.  
  109. <?If($use_subject_drop AND is_array($subjects)) {?>
  110. <select name="emailsubject" size="1">
  111. <?while(list($key,$val)=each($subjects)) {?>
  112.  
  113. <option value="<?=intval($key);?>"><?=htmlspecialchars(stripslashes($val));?></option>
  114.  
  115. <?}?>
  116. </select>
  117.  
  118.  
  119. <?} Else {?>
  120.  
  121. <input name="emailsubject" type="text" size="30" value="<?=stripslashes(htmlspecialchars($emailsubject));?>" />
  122.  
  123. <?}?>
  124.  
  125. </td>
  126. </tr>
  127.  
  128. <?For($i=1;$i <= $allowattach; $i++) {?>
  129. <tr>
  130. <td width="50%" class="table_body">Załącz plik:</td>
  131. <td width="50%" class="table_body"><input name="attachment[]" type="file" /></td>
  132. </tr>
  133. <?}?>
  134.  
  135. <tr>
  136. <td colspan="2" width="100%" class="table_body">Twoja wiadomość:<span class="error_message">*</span><br />
  137. <div align="center">
  138. <textarea name="yourmessage" rows="8" cols="60" placeholder="Ewentualne dodatkowe uwagi lub pytania"><?=stripslashes(htmlspecialchars($yourmessage));?></textarea>
  139. </div>
  140. </td>
  141. </tr>
  142. <tr>
  143. <td width="50%" class="table_footer"><input type="hidden" name="submit" value="true" />
  144. <input type="submit" value="<?=$submitvalue;?>" class="btn-1" /></td><td width="50%" class="table_footer"><input type="reset" value="<?=$resetvalue;?>" class="btn-1" />
  145. </td>
  146. </tr>
  147. <?If($allowattach > 0) {?>
  148. <tr>
  149. <td width="100%" class="attach_info" colspan="2">
  150. <b>Dopuszczalne rozszerzenia:</b> <?=implode($allowtypes, ", ");?><br />
  151. <b>Maksymalny rozmiar pliku</b> <?=$max_file_size?>kb.<br />
  152. <b>Maksymalny rozmiar plików:</b> <?=$max_file_total?>kb.
  153. </td>
  154. </tr>
  155. <?}?>
  156. </form>
  157.  
  158. <?} Else {?>
  159.  
  160. <div align="center" class="thanks_message"><?=$thanksmessage;?></div>
  161. <br />
  162. <br />
  163.  
  164. <?}
  165.  
  166. </body>
  167. </html>

[/html]

Poradziłem sobie.
Temat do zamknięcia.

BTW. polecam ten skrypt. przy niewielkiej znajomości PHP można go dostosować do własnych potrzeb oraz zmienić CSS.

Tutaj do pobrani: http://www.phphq.net/scripts.php?script=phMailer#phMailer