Hey Guys,
I really seems to be struggling here,
The Script is to Run through a Directory on the server, Zip it up and Connected to the SQL Database, make a Dump of it and add that to the Compressed File.
At the end of the Script it Emails me the Site its backed up and a Link to the File
(Then Also a Link to delete the backup once its downloaded)
The Problem is i cannot seem to get a CC Code working on the Email part,
Here is the Code in Different Parts of Files:
All am trying to do is to send it to 2 email Address,
Config File:
[code=php]$sitename = “COMPANY NAME”;
$siteaddress = “www.DOMAIN NAME.co.uk”;
$backupName = “BACKUPNAME-“.date(‘d-m-y’).’.zip’;
$downloadlink = “$siteaddress/Backup/backup/$backupName”;
$deletefile =”$siteaddress/Backup/delete.php”;
$configEmail = ‘EMAIL ADDRESS’;
Functions File:
[code=php]function mailAttachment($file, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
// $filename = basename($file);
// $file_size = filesize($file);
$handle = fopen($file, “r”);
// $content = fread($handle, $file_size);
fclose($handle);
// $content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
// $name = basename($file);
$header = “From: “.$from_name.” <“.$from_mail.”>rn”;
$header .= “Reply-To: “.$replyto.”rn”;
$header .= “MIME-Version: 1.0rn”;
$header .= “Content-Type: multipart/mixed; boundary=””.$uid.””rnrn”;
$headers .= “Content-Transfer-Encoding: 7bit”.”rn”;
$header .= “This is a multi-part message in MIME format.rn”;
$header .= “–“.$uid.”rn”;
$header .= “Content-type:text/html; charset=iso-8859-1rn”;
$header .= “Content-Transfer-Encoding: 8bitrnrn”;
$header .= $message.”rnrn”;
$header .= “–“.$uid.”rn”;
$header .= “Content-Type: application/octet-stream; name=””.$filename.””rn”; // use diff. tyoes here
$header .= “Content-Transfer-Encoding: base64rn”;
$header .= “Content-Disposition: attachment; filename=””.$filename.””rnrn”;
// $header .= $content.”rnrn”;
$header .= “–“.$uid.”–“;
if (mail($mailto, $subject, “”, $header)) {
echo “Backup has been Complete Email Sent”; // or use booleans here
} else {
echo “There has been a Error Please Contact Dave”;
}
}
Backup File:
[code=php]if (isset($configEmail) && !empty($configEmail))
{
mailAttachment($fileName,$configEmail,’[email protected]’,’Website Backup Complete’,’[email protected]’,”.$siteaddress,”The Backup has been Completed Sucsesfully for: <br><br> $sitename, <br> <br> Please Download The Back and Remove From the Server <br> <br> Domain $siteaddress <br> <br> <br> Download Link: $downloadlink <br> <br> <br> Once Downloaded Click the following link to delete the file <br> $deletefile <br> <br> <br> <br> <br> <br> Regards <br> <br> Dave”);
}
Thanks