Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Wysyłanie maili z załącznikiem
felixk
post
Post #1





Grupa: Zarejestrowani
Postów: 90
Pomógł: 1
Dołączył: 31.01.2009
Skąd: Ostrołęka

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


Witam, próbuję napisać kod, który będzie wysyłał maila z załącznikiem dołączanym z jednej i tej samej lokalizacji. Problem w tym, że mail dociera, ale bez załącznika. Jakieś pomysły czemu tak jest?

  1. File for Attachment
  2. $f_name="/home/..../public_html/test/backup_db/".$letter; // use relative path OR ELSE big headaches. $letter is my file for attaching.
  3. $handle=fopen($f_name, 'rb');
  4. $f_contents=fread($handle, filesize($f_name));
  5. $a = var_dump($handle); echo $a; exit;
  6. $f_contents=chunk_split(base64_encode($f_contents)); //Encode The Data For Transition using base64_encode();
  7. $f_type=filetype($f_name);
  8. fclose($handle);
  9. # To Email Address
  10. $emailaddress="test@test.pl";
  11. # Message Subject
  12. $emailsubject="Automatyczna kopia bazy danych";
  13.  
  14. # Common Headers
  15. $headers .= 'From: Administracja <tpdoka@neptun.os.pl>'.$eol;
  16. $headers .= 'Reply-To: Administracja <tpdoka@neptun.os.pl>'.$eol;
  17. $headers .= 'Return-Path: Administracja <tpdoka@neptun.os.pl>'.$eol; // these two to set reply address
  18. $headers .= "Message-ID:<".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
  19. $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
  20. # Boundry for marking the split & Multitype Headers
  21. $mime_boundary=md5(time());
  22. $headers .= 'MIME-Version: 1.0'.$eol;
  23. $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
  24. $msg = "";
  25.  
  26. # Attachment
  27. $msg = "W dniu $data nastąpiło utworzenie kopii bazy danych. Proszę o zachowanie załącznika."; // finish with two eol's for better security. see Injection.
  28.  
  29. mail($emailaddress, $emailsubject, $msg, $headers);
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 24.12.2025 - 19:51