Forum Moderators: coopster
set_time_limit ( 0 );
$date = date("Ymd"); $to = "email@googlemail.com";
$from = "webserver@example.net";
$from_name = "Backups";
$subject = "Daily Backup";
$message = "Daily Backup";
$attachments = array();
$attachments[0]="../Backups/sp".$date.".tar.gz";
$attachments[1]="../Backups/Bg".$date.".tar.gz";
$attachments[2]="../Backups/DatabaseBackups".$date.".tar.gz";
send_email($to, $from, $from_name, $subject, $message, $attachments);
unset ($attachments[2]);
unset ($attachments[1]);
unset ($attachments[0]);
$attachments[0]="../Backups/sidekick".$date.".tar.gz";
send_email($to, $from, $from_name, $subject, $message, $attachments);
[edited by: eelixduppy at 1:17 pm (utc) on July 23, 2008]
function is:
function send_email($to, $from, $from_name, $subject, $message, $attachments=false)
{
$headers = "From: ".$from_name."<".$from.">\n";
$headers .= "Reply-To: ".$from_name."<".$from.">\n";
$headers .= "Return-Path: ".$from_name."<".$from.">\n";
$headers .= "Message-ID: <".time()."-".$from.">\n";
$headers .= "X-Mailer: PHP v".phpversion();$msg_txt="";
$email_txt = $message;
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_txt .= $msg_txt;
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_txt . "\n\n";
if ($attachments !== false)
{
for($i=0; $i < count($attachments); $i++)
if (is_file($attachments[$i]))
{
$fileatt = $attachments[$i];
$fileatt_type = "application/octet-stream";
$start= strrpos($attachments[$i], '/') == -1 ? strrpos($attachments[$i], '//') : strrpos($attachments[$i], '/')+1;
$fileatt_name = substr($attachments[$i], $start, strlen($attachments[$i]));
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
}
$email_message .= "--{$mime_boundary}--\n";
return mail($to, $subject, $email_message, $headers);
}
unset ($attachments[2]);
unset ($attachments[1]);
unset ($attachments[0]);
$attachments = array();
$path = "/bin/split -b n m 10 /mounted-storage/home1/sub002/sc183-LGVN/Backups/side".$date.".tar.gz new";
$c_pid = system($path, $retval);
$attachments[0]="../Backups/side".$date.".tar.gz";
send_email($to, $from, $from_name, $subject, $message, $attachments);
Can you elaborate? Are you getting any errors? Are you running in safe mode? Have you tried running this commands directly from the console? Have you tried echoing out
$path to see if it contains what you think it contains?