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?
$f_name="/home/..../public_html/test/backup_db/".$letter; // use relative path OR ELSE big headaches. $letter is my file for attaching.
$handle=fopen($f_name, 'rb'); # To Email Address
$emailaddress="test@test.pl";
# Message Subject
$emailsubject="Automatyczna kopia bazy danych";
# Common Headers
$headers .= 'From: Administracja <tpdoka@neptun.os.pl>'.$eol;
$headers .= 'Reply-To: Administracja <tpdoka@neptun.os.pl>'.$eol;
$headers .= 'Return-Path: Administracja <tpdoka@neptun.os.pl>'.$eol; // these two to set reply address
$headers .= "Message-ID:<".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters # Boundry for marking the split & Multitype Headers
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
$msg = "";
# Attachment
$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.
mail($emailaddress, $emailsubject, $msg, $headers);