login  Naam:   Wachtwoord: 
Registreer je!
 Forum

MAIL met meerdere bijlages!

Offline Tony_mortana - 28/10/2005 17:52
Avatar van Tony_mortanaPHP interesse Weet iemand hoe de code zo te veranderen
dat er meer dan 1 bijlage mee gestuurd kan worden!
(PS: het script werkt perfect maar wat ik ook probeer
komt maar 1 bijlage bij)

zie:
http://www.site...amp;id=183

code:
  1. <?php
  2. $fileatt = ""; // Path to the file
  3. $fileatt_type = "application/octet-stream"; // File Type
  4. $fileatt_name = ""; // Filename that will be used for the file as the attachment
  5.  
  6. $email_from = ""; // Who the email is from
  7. $email_subject = ""; // The Subject of the email
  8. $email_message = ""; // Message that the email has in it
  9.  
  10. $email_to = ""; // Who the email is too
  11.  
  12. $headers = "From: $email_from";
  13.  
  14. $file = fopen($fileatt,'rb');
  15. $data = fread($file,filesize($fileatt));
  16. fclose($file);
  17.  
  18. $semi_rand = md5(time());
  19. $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
  20.  
  21. $headers .= "\nMIME-Version: 1.0\n" .
  22. "Content-Type: multipart/mixed;\n" .
  23. " boundary=\"{$mime_boundary}\"";
  24.  
  25. $email_message = "This is a multi-part message in MIME format.\n\n" .
  26. "--{$mime_boundary}\n" .
  27. "Content-Type:text/html; charset=\"iso-8859-1\"\n" .
  28. "Content-Transfer-Encoding: 7bit\n\n" .
  29. $email_message . "\n\n";
  30.  
  31. $data = chunk_split(base64_encode($data));
  32.  
  33. $email_message .= "--{$mime_boundary}\n" .
  34. "Content-Type: {$fileatt_type};\n" .
  35. " name=\"{$fileatt_name}\"\n" .
  36. //"Content-Disposition: attachment;\n" .
  37. //" filename=\"{$fileatt_name}\"\n" .
  38. "Content-Transfer-Encoding: base64\n\n" .
  39. $data . "\n\n" .
  40. "--{$mime_boundary}--\n";
  41.  
  42. $ok = @mail($email_to, $email_subject, $email_message, $headers);
  43.  
  44. if($ok) {
  45. echo "<font face=verdana size=2>The file was successfully sent!</font>";
  46. } else {
  47. die("Sorry but the email could not be sent. Please go back and try again!");
  48. }
  49. ?>


heb zelf hier zitte klote maar werkt niet!
  1. $email_message .= "--{$mime_boundary}\n" .
  2. "Content-Type: {$fileatt_type};\n" .
  3. " name=\"{$fileatt_name}\"\n" .
  4. //"Content-Disposition: attachment;\n" .
  5. //" filename=\"{$fileatt_name}\"\n" .
  6. "Content-Transfer-Encoding: base64\n\n" .
  7. $data . "\n\n" .
  8. "--{$mime_boundary}--\n";

1 antwoord

Gesponsorde links
Offline Thomas - 28/10/2005 18:33
Avatar van Thomas Moderator Dan moet je een multipart MIME-message bouwen, en deze dan scheiden met boundaries, dus als in bovenstaand voorbeeld, maar dan wat uitgebreider.
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.204s