Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zalaczniki Do E-maili Z Www, problem z zalacznikiem - pusty plik
taktiken
post
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 10.08.2004
Skąd: Uć

Ostrzeżenie: (0%)
-----


Czesc,
wysylam maile przez www - logowanie na zewnetrzny serwer, bez zastosowania mail() (modyfikacja funkcji smtp_mail znalezionej na forum z uzyciem sockets). Problem jest taki ze zalacznik do maila sie wysyla ale jego zawartosc jest pusta.
Dlaczego tak sie dzieje? Bardzo bede wdzieczny za pomoc.
Thx,
Jac


--------------------
------------------------
e tam...
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Bakus
post
Post #2


Administrator serwera


Grupa: Przyjaciele php.pl
Postów: 909
Pomógł: 0
Dołączył: 12.08.2003
Skąd: /var/www/wroclaw.php

Ostrzeżenie: (0%)
-----


trudno to powiedzieć nie mając choćby kilku linijek wspomnianej funkcji....
wrzuć na forum listing lub link do niego...


--------------------
Powrót do przeszłości :)
Go to the top of the page
+Quote Post
taktiken
post
Post #3





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 10.08.2004
Skąd: Uć

Ostrzeżenie: (0%)
-----


Ok, zalaczam. Sorry za smietnik, ale to tylko testowanie...
  1. <?php include(&#092;"./header.inc\"); ?>
  2. <FORM ACTION=\"send.php\" METHOD=\"POST\" ENCTYPE=\"multipart/form-data\">
  3. // ten input poniżej służy do tego aby ograniczyć wielkość przesyłki
  4. // sciagniete z forum.php.pl
  5. <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"4096\">
  6. <input type=\"text\" name=\"from\" VALUE=\"MAGGOT\">
  7. <input type=\"text\" name=\"temat\">
  8. <input type=\"file\" name=\"attach\">
  9. <textarea cols=55 rows=10 name=\"tresc\" wrap=\"message\"></textarea>
  10. <input type=\"submit\" value=\"Wyślij\" name=\"mail\">
  11. <input type=\"reset\" value=\"Wyczyść\">
  12. </FORM>
  13. <?php 
  14.  
  15. $attach = 'C:Documents and SettingsAdministratorPulpitaaaa.txt';
  16. $attach_name = 'aaaa.txt';
  17. // logowanie serwer
  18. $smtp_host = '';  
  19. $smtp_user = '';  
  20. $smtp_pass = '';
  21. $email = '';  
  22. // wypelnione 'live'
  23. /* Funkcja do wysyłania maili bez użycia funkcji mail(), znaleziona w forum phpBB... */ 
  24. function smtp_mail($mail_to, $subject, $mailheaders, $message) { 
  25. global $smtp_host, $smtp_user, $smtp_pass, $email, $attach, $attach_name; 
  26.  
  27. if($mail_to == '') 
  28. $error = 'Nie podałeś adresu odbiorcy!'; 
  29. if(trim($subject) == '') 
  30. $error = 'Nie podałeś tematu wiadomości!'; 
  31. if(trim($message) == '') 
  32. $error = 'Wiadomość jest pusta!'; 
  33. if(!$socket = pfsockopen($smtp_host, 25, $errno, $errstr, 20)) 
  34. $error = 'Nie mogę się połączyć z serwerem SMTP!'; 
  35.  
  36. if(!empty($error)){ 
  37. echo &#092;"<B>Błąd: </B>$error<BR>n\"; 
  38. return false; 
  39. } 
  40.  
  41. server_parse($socket, '220'); 
  42.  
  43. if(!empty($smtp_user) && !empty($smtp_pass)){ 
  44. fputs($socket, 'EHLO '.$smtp_host.&#092;"rn\"); 
  45. server_parse($socket, '250'); 
  46. fputs($socket, &#092;"AUTH LOGINrn\"); 
  47. server_parse($socket, '334'); 
  48. fputs($socket, base64_encode($smtp_user).&#092;"rn\"); 
  49. server_parse($socket, '334'); 
  50. fputs($socket, base64_encode($smtp_pass).&#092;"rn\"); 
  51. server_parse($socket, '235'); 
  52. } 
  53. else{ 
  54. fputs($socket, 'HELO '.$smtp_host.&#092;"rn\"); 
  55. server_parse($socket, '250'); 
  56. } 
  57.  
  58. fputs($socket, 'MAIL FROM: <' . $email . &#092;">rn\"); 
  59. server_parse($socket, '250'); 
  60.  
  61. $mail_to_array = explode(',', $mail_to); 
  62.  
  63.  
  64. $to_header = 'To: '; 
  65. @reset($mail_to_array); 
  66.  
  67. foreach($mail_to_array as $mail_to){ 
  68. $mail_to = trim($mail_to); 
  69.  
  70. if (preg_match('/[^ ]+@[^ ]+/', $mail_to)) { 
  71. fputs( $socket, &#092;"RCPT TO: <$mail_to>rn\" ); 
  72. server_parse($socket, '250'); 
  73. } 
  74. $to_header .= (($mail_to != '') ? ', ' : '').&#092;"<$mail_to>\"; 
  75. } 
  76.  
  77. $message = preg_replace(&#092;"/(?<!r)n/si\", \"rn\", $message); 
  78.  
  79. fputs($socket, &#092;"DATArn\"); 
  80. server_parse($socket, &#092;"354\"); 
  81. fputs($socket, &#092;"Subject: $subjectrn\"); 
  82. fputs($socket, &#092;"$to_headerrn\"); 
  83. // file open
  84. $file = fopen($attach, &#092;"r\"); 
  85. $attach_size = filesize($attach);
  86. $contents = fread($file, $attach_size); 
  87. $encoded_attach = chunk_split(base64_encode($contents)); 
  88. fclose($file); 
  89.  
  90. fputs($socket, &#092;"$mailheadersrn\"); 
  91. fputs($socket, &#092;"$messagern\"); 
  92. fputs($socket, &#092;".rn\"); 
  93. server_parse($socket, '250'); 
  94. fputs($socket, &#092;"QUITrn\"); 
  95. fclose($socket); 
  96.  
  97. return true; 
  98. } 
  99. function server_parse($socket, $response) { 
  100. while (substr($server_response,3,1)!=' ') { 
  101. if(!($server_response=fgets($socket, 256))) { 
  102. die('Nie mogę pobrać kodów zwróconych przez serwer.'); 
  103. } 
  104. } 
  105. if(!(substr($server_response, 0, 3) == $response)) { 
  106. die('Wystąpił problem z wysyłaniem maili. Serwer zwrócił komunikat: 
  107. '.$server_response); 
  108. } 
  109. 'Serwer zwrócił komunikat: '.$server_response; 
  110. } 
  111. $mail_to = 'test@test.com';
  112.     $mailheaders = &#092;"From: $emailn\"; 
  113.     $mailheaders .= &#092;"Reply-To: $emailn\"; 
  114.     $mailheaders .= &#092;"Cc: $ccn\"; 
  115.     $mailheaders .= &#092;"X-Mailer: Server Web Email Interfacen\";
  116.     $mailheaders .= &#092;"MIME-version: 1.0n\"; 
  117.     $mailheaders .= &#092;"Content-type: multipart/mixed; \"; 
  118.     $mailheaders .= &#092;"boundary=\"Message-Boundary\"n\"; 
  119.     $mailheaders .= &#092;"Content-transfer-encoding: 7BITn\";
  120.     $mailheaders .= &#092;"X-attachments: $attach_name\"; 
  121. $subject = 'test ze strony2'; // wlasciwa tresc wiadomosci
  122.     $body_top = &#092;"--Message-Boundaryn\"; 
  123.     $body_top .= &#092;"Content-type: text/plain; charset=iso-8859-2n\"; 
  124.     $body_top .= &#092;"Content-transfer-encoding: 7BITn\";
  125.     $body_top .= &#092;"Content-description: Mail message bodynn\"; 
  126.     $msg_body .= &#092;"nn--Message-Boundaryn\"; 
  127.     $msg_body .= &#092;"Content-type: $attach_type; name=\"$attach_name\"n\"; 
  128.     $msg_body .= &#092;"Content-Transfer-Encoding: BASE64n\"; 
  129.     $msg_body .= &#092;"Content-disposition: attachment; filename=\"$attach_name\"nn\"; 
  130.     $msg_body .= &#092;"$encoded_attachn\"; 
  131.     $msg_body .= &#092;"--Message-Boundary--n\"; 
  132. $message =  $body_top . 'test' . $msg_body;
  133.     
  134. smtp_mail($mail_to, $subject, $mailheaders, $message);
  135. ?>

To czego nie okreslam w kodzie to
Kod
$attach_type
. Moze tu jest problem?? Ustawienia
Kod
$attach i $attach_name
sa na sztywno.
Nagłówek internetowy otrzymanej wiadomości:
Kod
Return-path: <test@test.pl>
Envelope-to: test2@test.pl
Delivery-date: Mon, 06 Sep 2004 12:28:13 +0200
Received: ...
Subject: test ze strony2
To:    <dom@dom.com>
From:    test@test.pl
Reply-To: test@test.pl
X-Mailer: Server Web Email Interface
MIME-version: 1.0
Content-type: multipart/mixed; boundary="Message-Boundary"
Content-transfer-encoding: 7BIT
X-attachments: aaaa.txt
Message-Id: <20040906102618Z847954-8443+167074@ps3.test.onet.pl>
Date:    Mon, 6 Sep 2004 12:26:18 +0200
X-Bogosity: No, tests=bogofilter, spamicity=0.000000

dzieki za uwagi.
Ja
========================
juz po sprawie.. kto szuka i czyta manuale....
offtopic.gif
/J

Ten post edytował taktiken 21.11.2004, 22:54:25


--------------------
------------------------
e tam...
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 19:18